home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / dev / gcc / gcc270_src.lha / gcc-2.7.0-amiga / config / m68k / m68k.c < prev    next >
C/C++ Source or Header  |  1995-08-24  |  71KB  |  2,679 lines

  1. /* Subroutines for insn-output.c for Motorola 68000 family.
  2.    Copyright (C) 1987, 1993, 1994, 1995 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 59 Temple Place - Suite 330,
  19. Boston, MA 02111-1307, USA.  */
  20.  
  21.  
  22. /* Some output-actions in m68k.md need these.  */
  23. #include <stdio.h>
  24. #include "config.h"
  25. #include "rtl.h"
  26. #include "regs.h"
  27. #include "hard-reg-set.h"
  28. #include "real.h"
  29. #include "insn-config.h"
  30. #include "conditions.h"
  31. #include "insn-flags.h"
  32. #include "output.h"
  33. #include "insn-attr.h"
  34.  
  35. /* Needed for use_return_insn.  */
  36. #include "flags.h"
  37.  
  38. #ifdef SUPPORT_SUN_FPA
  39.  
  40. /* Index into this array by (register number >> 3) to find the
  41.    smallest class which contains that register.  */
  42. enum reg_class regno_reg_class[]
  43.   = { DATA_REGS, ADDR_REGS, FP_REGS,
  44.       LO_FPA_REGS, LO_FPA_REGS, FPA_REGS, FPA_REGS };
  45.  
  46. #endif /* defined SUPPORT_SUN_FPA */
  47.  
  48. /* This flag is used to communicate between movhi and ASM_OUTPUT_CASE_END,
  49.    if SGS_SWITCH_TABLE.  */
  50. int switch_table_difference_label_flag;
  51.  
  52. static rtx find_addr_reg ();
  53. rtx legitimize_pic_address ();
  54.  
  55.  
  56. /* Emit a (use pic_offset_table_rtx) if we used PIC relocation in the 
  57.    function at any time during the compilation process.  In the future 
  58.    we should try and eliminate the USE if we can easily determine that 
  59.    all PIC references were deleted from the current function.  That would 
  60.    save an address register */
  61.    
  62. void
  63. finalize_pic ()
  64. {
  65.   if (flag_pic && (flag_pic < 3) && current_function_uses_pic_offset_table)
  66.     {
  67.       rtx insn = gen_rtx (USE, VOIDmode, pic_offset_table_rtx);
  68. #ifndef __amigados__
  69.       emit_insn_after (insn, get_insns ());
  70. #endif
  71.       emit_insn (insn);
  72.     }
  73. }
  74.  
  75.  
  76. /* This function generates the assembly code for function entry.
  77.    STREAM is a stdio stream to output the code to.
  78.    SIZE is an int: how many units of temporary storage to allocate.
  79.    Refer to the array `regs_ever_live' to determine which registers
  80.    to save; `regs_ever_live[I]' is nonzero if register number I
  81.    is ever used in the function.  This function is responsible for
  82.    knowing which registers should not be saved even if used.  */
  83.  
  84.  
  85. /* Note that the order of the bit mask for fmovem is the opposite
  86.    of the order for movem!  */
  87.  
  88.  
  89. void
  90. output_function_prologue (stream, size)
  91.      FILE *stream;
  92.      int size;
  93. {
  94.   register int regno;
  95.   register int mask = 0;
  96.   int num_saved_regs = 0;
  97.   extern char call_used_regs[];
  98.   int fsize = (size + 3) & -4;
  99.  
  100.  
  101. /* Matthias Fleischer stack-checking and auto-extend for the Amiga */  
  102. #ifndef MOTOROLA
  103.   if (TARGET_STACKCHECK)
  104.     {
  105.       if (fsize<256)
  106.         asm_fprintf (stream, "\tjbsr ___stkchk_0\n");
  107.       else if(fsize<0x8000)
  108.         asm_fprintf (stream, "\tmovel #%d:W,d0\n\tjbsr ___stkchk_d0\n",
  109.                  fsize, reg_names[FRAME_POINTER_REGNUM]);
  110.       else
  111.         asm_fprintf (stream, "\tmovel #%d,d0\n\tjbsr ___stkchk_d0\n",
  112.                  fsize, reg_names[FRAME_POINTER_REGNUM]);
  113.     }
  114. #endif
  115.   if (frame_pointer_needed)
  116.     {
  117. /* Matthias Fleischer stack-checking and auto-extend for the Amiga */  
  118. #ifndef MOTOROLA
  119.       if (TARGET_STACKEXTEND)
  120.         {
  121.           if (!fsize)
  122.         asm_fprintf (stream, "\tjbsr ___link_%s_0_f\n",
  123.                      reg_names[FRAME_POINTER_REGNUM]);
  124.       else if(fsize<0x8000)
  125.          asm_fprintf (stream, "\tmovel #%d:W,d0\n\tjbsr ___link_%s_d0_f\n",
  126.                    fsize, reg_names[FRAME_POINTER_REGNUM]);
  127.           else
  128.          asm_fprintf (stream, "\tmovel #%d,d0\n\tjbsr ___link_%s_d0_f\n",
  129.                    fsize, reg_names[FRAME_POINTER_REGNUM]);
  130.     }
  131.       else
  132. #endif
  133.       if (fsize == 0 && TARGET_68040)
  134.     {
  135.     /* on the 68040, pea + move is faster than link.w 0 */
  136. #ifdef MOTOROLA
  137.       asm_fprintf (stream, "\tpea (%s)\n\tmove.l %s,%s\n",
  138.            reg_names[FRAME_POINTER_REGNUM], reg_names[STACK_POINTER_REGNUM],
  139.            reg_names[FRAME_POINTER_REGNUM]);
  140. #else
  141.       asm_fprintf (stream, "\tpea %s@\n\tmovel %s,%s\n",
  142.            reg_names[FRAME_POINTER_REGNUM], reg_names[STACK_POINTER_REGNUM],
  143.            reg_names[FRAME_POINTER_REGNUM]);
  144. #endif
  145.     }
  146.       else if (fsize < 0x8000)
  147.     {
  148. #ifdef MOTOROLA
  149.       asm_fprintf (stream, "\tlink.w %s,%0I%d\n",
  150.                reg_names[FRAME_POINTER_REGNUM], -fsize);
  151. #else
  152.       asm_fprintf (stream, "\tlink %s,%0I%d\n",
  153.                reg_names[FRAME_POINTER_REGNUM], -fsize);
  154. #endif
  155.     }
  156.       else if (TARGET_68020)
  157.     {
  158. #ifdef MOTOROLA
  159.       asm_fprintf (stream, "\tlink.l %s,%0I%d\n",
  160.                reg_names[FRAME_POINTER_REGNUM], -fsize);
  161. #else
  162.       asm_fprintf (stream, "\tlink %s,%0I%d\n",
  163.                reg_names[FRAME_POINTER_REGNUM], -fsize);
  164. #endif
  165.     }
  166.       else
  167.     {
  168.       /* Adding negative number is faster on the 68040.  */
  169. #ifdef MOTOROLA
  170.       asm_fprintf (stream, "\tlink.w %s,%0I0\n\tadd.l %0I%d,%Rsp\n",
  171.                reg_names[FRAME_POINTER_REGNUM], -fsize);
  172. #else
  173.       asm_fprintf (stream, "\tlink %s,%0I0\n\taddl %0I%d,%Rsp\n",
  174.                reg_names[FRAME_POINTER_REGNUM], -fsize);
  175. #endif
  176.     }
  177.     }
  178. /* Matthias Fleischer stack-checking and auto-extend for the Amiga */  
  179. #ifndef MOTOROLA
  180.   else if (TARGET_STACKEXTEND)
  181.     {
  182.       if (!fsize)
  183.         asm_fprintf (stream, "\tjbsr ___sub_0_sp_f\n");
  184.       else if (fsize+4<0x8000)
  185.     asm_fprintf (stream, "\tmovel #%d:W,d0\n\tjbsr ___sub_d0_sp_f\n",
  186.                fsize + 4, reg_names[FRAME_POINTER_REGNUM]);
  187.       else
  188.     asm_fprintf (stream, "\tmovel %0I%d,d0\n\tjbsr ___sub_d0_sp_f\n",
  189.                fsize + 4, reg_names[FRAME_POINTER_REGNUM]);
  190.     }
  191. #endif
  192.   else if (fsize)
  193.     {
  194.       /* Adding negative number is faster on the 68040.  */
  195.       if (fsize + 4 < 0x8000)
  196.     {
  197.     /* asm_fprintf() cannot handle %. */
  198. #ifdef MOTOROLA
  199.       asm_fprintf (stream, "\tadd.w %0I%d,%Rsp\n", - (fsize + 4));
  200. #else
  201.       asm_fprintf (stream, "\taddw %0I%d,%Rsp\n", - (fsize + 4));
  202. #endif
  203.     }
  204.       else
  205.     {
  206.     /* asm_fprintf() cannot handle %. */
  207. #ifdef MOTOROLA
  208.       asm_fprintf (stream, "\tadd.l %0I%d,%Rsp\n", - (fsize + 4));
  209. #else
  210.       asm_fprintf (stream, "\taddl %0I%d,%Rsp\n", - (fsize + 4));
  211. #endif
  212.     }
  213.     }
  214. #ifdef SUPPORT_SUN_FPA
  215.   for (regno = 24; regno < 56; regno++)
  216.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  217.       {
  218. #ifdef MOTOROLA
  219.     asm_fprintf (stream, "\tfpmovd %s,-(%Rsp)\n",
  220.              reg_names[regno]);
  221. #else
  222.     asm_fprintf (stream, "\tfpmoved %s,%Rsp@-\n",
  223.              reg_names[regno]);
  224. #endif
  225.       }
  226. #endif
  227.   for (regno = 16; regno < 24; regno++)
  228.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  229.        mask |= 1 << (regno - 16);
  230.   if ((mask & 0xff) != 0)
  231.     {
  232. #ifdef MOTOROLA
  233.       asm_fprintf (stream, "\tfmovm %0I0x%x,-(%Rsp)\n", mask & 0xff);
  234. #else
  235.       asm_fprintf (stream, "\tfmovem %0I0x%x,%Rsp@-\n", mask & 0xff);
  236. #endif
  237.     }
  238.   mask = 0;
  239.   for (regno = 0; regno < 16; regno++)
  240.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  241.       {
  242.         mask |= 1 << (15 - regno);
  243.         num_saved_regs++;
  244.       }
  245.   if (frame_pointer_needed)
  246.     {
  247.       mask &= ~ (1 << (15 - FRAME_POINTER_REGNUM));
  248.       num_saved_regs--;
  249.     }
  250. #ifdef PROLOGUE_EXTRA_SAVE
  251.   PROLOGUE_EXTRA_SAVE (mask);
  252. #endif
  253.  
  254. #if NEED_PROBE
  255.   fprintf (stream, "\ttstl sp@(%d)\n", NEED_PROBE - num_saved_regs * 4);
  256. #endif
  257.  
  258.   if (num_saved_regs <= 2)
  259.     {
  260.       /* Store each separately in the same order moveml uses.
  261.          Using two movel instructions instead of a single moveml
  262.          is about 15% faster for the 68020 and 68030 at no expense
  263.          in code size */
  264.  
  265.       int i;
  266.  
  267.       /* Undo the work from above. */
  268.       for (i = 0; i< 16; i++)
  269.         if (mask & (1 << i))
  270.           asm_fprintf (stream,
  271. #ifdef MOTOROLA
  272.                "\t%Omove.l %s,-(%Rsp)\n",
  273. #else
  274.                "\tmovel %s,%Rsp@-\n",
  275. #endif
  276.                reg_names[15 - i]);
  277.     }
  278.   else if (mask)
  279.     {
  280. #ifdef MOTOROLA
  281.       asm_fprintf (stream, "\tmovm.l %0I0x%x,-(%Rsp)\n", mask);
  282. #else
  283.       asm_fprintf (stream, "\tmoveml %0I0x%x,%Rsp@-\n", mask);
  284. #endif
  285.     }
  286.   if (flag_pic && (flag_pic < 3) && current_function_uses_pic_offset_table)
  287.     {
  288. #ifdef MOTOROLA
  289.       asm_fprintf (stream, "\t%Olea (%Rpc, %U_GLOBAL_OFFSET_TABLE_@GOTPC), %s\n",
  290.            reg_names[PIC_OFFSET_TABLE_REGNUM]);
  291. #else
  292.       asm_fprintf (stream, "\tmovel %0I__GLOBAL_OFFSET_TABLE_, %s\n",
  293.            reg_names[PIC_OFFSET_TABLE_REGNUM]);
  294.       asm_fprintf (stream, "\tlea %Rpc@(0,%s:l),%s\n",
  295.            reg_names[PIC_OFFSET_TABLE_REGNUM],
  296.            reg_names[PIC_OFFSET_TABLE_REGNUM]);
  297. #endif
  298.     }
  299. }
  300.  
  301. /* Return true if this function's epilogue can be output as RTL.  */
  302.  
  303. int
  304. use_return_insn ()
  305. {
  306.   int regno;
  307.  
  308.   if (!reload_completed || frame_pointer_needed || get_frame_size () != 0)
  309.     return 0;
  310.   
  311.   /* Copied from output_function_epilogue ().  We should probably create a
  312.      separate layout routine to perform the common work.  */
  313.   
  314.   for (regno = 0 ; regno < FIRST_PSEUDO_REGISTER ; regno++)
  315.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  316.       return 0;
  317.   
  318.   return 1;
  319. }
  320.  
  321. /* This function generates the assembly code for function exit,
  322.    on machines that need it.  Args are same as for FUNCTION_PROLOGUE.
  323.  
  324.    The function epilogue should not depend on the current stack pointer!
  325.    It should use the frame pointer only, if there is a frame pointer.
  326.    This is mandatory because of alloca; we also take advantage of it to
  327.    omit stack adjustments before returning.  */
  328.  
  329. void
  330. output_function_epilogue (stream, size)
  331.      FILE *stream;
  332.      int size;
  333. {
  334.   register int regno;
  335.   register int mask, fmask;
  336.   register int nregs;
  337.   int offset, foffset, fpoffset;
  338.   extern char call_used_regs[];
  339.   int fsize = (size + 3) & -4;
  340.   int big = 0;
  341.   rtx insn = get_last_insn ();
  342.   
  343.   /* If the last insn was a BARRIER, we don't have to write any code.  */
  344.   if (GET_CODE (insn) == NOTE)
  345.     insn = prev_nonnote_insn (insn);
  346.   if (insn && GET_CODE (insn) == BARRIER)
  347.     {
  348.       /* Output just a no-op so that debuggers don't get confused
  349.      about which function the pc is in at this address.  */
  350.       asm_fprintf (stream, "\tnop\n");
  351. #ifdef EPILOGUE_EXTRA_BARRIER_KLUDGE
  352.       EPILOGUE_EXTRA_BARRIER_KLUDGE(stream);
  353. #endif
  354.       return;
  355.     }
  356.  
  357. #ifdef FUNCTION_EXTRA_EPILOGUE
  358.   FUNCTION_EXTRA_EPILOGUE (stream, size);
  359. #endif
  360.   nregs = 0;  fmask = 0; fpoffset = 0;
  361. #ifdef SUPPORT_SUN_FPA
  362.   for (regno = 24 ; regno < 56 ; regno++)
  363.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  364.       nregs++;
  365.   fpoffset = nregs * 8;
  366. #endif
  367.   nregs = 0;
  368.   for (regno = 16; regno < 24; regno++)
  369.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  370.       {
  371.         nregs++;
  372.     fmask |= 1 << (23 - regno);
  373.       }
  374.   foffset = fpoffset + nregs * 12;
  375.   nregs = 0;  mask = 0;
  376.   if (frame_pointer_needed)
  377.     regs_ever_live[FRAME_POINTER_REGNUM] = 0;
  378.   for (regno = 0; regno < 16; regno++)
  379.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  380.       {
  381.         nregs++;
  382.     mask |= 1 << regno;
  383.       }
  384. #ifdef EPILOGUE_EXTRA_RESTORE
  385.   EPILOGUE_EXTRA_RESTORE(mask, nregs);
  386. #endif
  387.   offset = foffset + nregs * 4;
  388.   if (offset + fsize >= 0x8000
  389.       && frame_pointer_needed
  390.       && (mask || fmask || fpoffset))
  391.     {
  392. #ifdef MOTOROLA
  393.       asm_fprintf (stream, "\t%Omove.l %0I%d,%Ra1\n", -fsize);
  394. #else
  395.       asm_fprintf (stream, "\tmovel %0I%d,%Ra1\n", -fsize);
  396. #endif
  397.       fsize = 0, big = 1;
  398.     }
  399.   if (nregs <= 2)
  400.     {
  401.       /* Restore each separately in the same order moveml does.
  402.          Using two movel instructions instead of a single moveml
  403.          is about 15% faster for the 68020 and 68030 at no expense
  404.          in code size. */
  405.  
  406.       int i;
  407.  
  408.       /* Undo the work from above. */
  409.       for (i = 0; i< 16; i++)
  410.         if (mask & (1 << i))
  411.           {
  412.             if (big)
  413.           {
  414. #ifdef MOTOROLA
  415.         asm_fprintf (stream, "\t%Omove.l -%d(%s,%Ra1.l),%s\n",
  416.                  offset + fsize,
  417.                  reg_names[FRAME_POINTER_REGNUM],
  418.                  reg_names[i]);
  419. #else
  420.         asm_fprintf (stream, "\tmovel %s@(-%d,%Ra1:l),%s\n",
  421.                  reg_names[FRAME_POINTER_REGNUM],
  422.                  offset + fsize, reg_names[i]);
  423. #endif
  424.           }
  425.             else if (! frame_pointer_needed)
  426.           {
  427. #ifdef MOTOROLA
  428.         asm_fprintf (stream, "\t%Omove.l (%Rsp)+,%s\n",
  429.                  reg_names[i]);
  430. #else
  431.         asm_fprintf (stream, "\tmovel %Rsp@+,%s\n",
  432.                  reg_names[i]);
  433. #endif
  434.           }
  435.             else
  436.           {
  437. #ifdef MOTOROLA
  438.         asm_fprintf (stream, "\t%Omove.l -%d(%s),%s\n",
  439.                  offset + fsize,
  440.                  reg_names[FRAME_POINTER_REGNUM],
  441.                  reg_names[i]);
  442. #else
  443.         asm_fprintf (stream, "\tmovel %s@(-%d),%s\n",
  444.                  reg_names[FRAME_POINTER_REGNUM],
  445.                  offset + fsize, reg_names[i]);
  446. #endif
  447.           }
  448.             offset = offset - 4;
  449.           }
  450.     }
  451.   else if (mask)
  452.     {
  453.       if (big)
  454.     {
  455. #ifdef MOTOROLA
  456.       asm_fprintf (stream, "\tmovm.l -%d(%s,%Ra1.l),%0I0x%x\n",
  457.                offset + fsize,
  458.                reg_names[FRAME_POINTER_REGNUM],
  459.                mask);
  460. #else
  461.       asm_fprintf (stream, "\tmoveml %s@(-%d,%Ra1:l),%0I0x%x\n",
  462.                reg_names[FRAME_POINTER_REGNUM],
  463.                offset + fsize, mask);
  464. #endif
  465.     }
  466.       else if (! frame_pointer_needed)
  467.     {
  468. #ifdef MOTOROLA
  469.       asm_fprintf (stream, "\tmovm.l (%Rsp)+,%0I0x%x\n", mask);
  470. #else
  471.       asm_fprintf (stream, "\tmoveml %Rsp@+,%0I0x%x\n", mask);
  472. #endif
  473.     }
  474.       else
  475.     {
  476. #ifdef MOTOROLA
  477.       asm_fprintf (stream, "\tmovm.l -%d(%s),%0I0x%x\n",
  478.                offset + fsize,
  479.                reg_names[FRAME_POINTER_REGNUM],
  480.                mask);
  481. #else
  482.       asm_fprintf (stream, "\tmoveml %s@(-%d),%0I0x%x\n",
  483.                reg_names[FRAME_POINTER_REGNUM],
  484.                offset + fsize, mask);
  485. #endif
  486.     }
  487.     }
  488.   if (fmask)
  489.     {
  490.       if (big)
  491.     {
  492. #ifdef MOTOROLA
  493.       asm_fprintf (stream, "\tfmovm -%d(%s,%Ra1.l),%0I0x%x\n",
  494.                foffset + fsize,
  495.                reg_names[FRAME_POINTER_REGNUM],
  496.                fmask);
  497. #else
  498.       asm_fprintf (stream, "\tfmovem %s@(-%d,%Ra1:l),%0I0x%x\n",
  499.                reg_names[FRAME_POINTER_REGNUM],
  500.                foffset + fsize, fmask);
  501. #endif
  502.     }
  503.       else if (! frame_pointer_needed)
  504.     {
  505. #ifdef MOTOROLA
  506.       asm_fprintf (stream, "\tfmovm (%Rsp)+,%0I0x%x\n", fmask);
  507. #else
  508.       asm_fprintf (stream, "\tfmovem %Rsp@+,%0I0x%x\n", fmask);
  509. #endif
  510.     }
  511.       else
  512.     {
  513. #ifdef MOTOROLA
  514.       asm_fprintf (stream, "\tfmovm -%d(%s),%0I0x%x\n",
  515.                foffset + fsize,
  516.                reg_names[FRAME_POINTER_REGNUM],
  517.                fmask);
  518. #else
  519.       asm_fprintf (stream, "\tfmovem %s@(-%d),%0I0x%x\n",
  520.                reg_names[FRAME_POINTER_REGNUM],
  521.                foffset + fsize, fmask);
  522. #endif
  523.     }
  524.     }
  525.   if (fpoffset != 0)
  526.     for (regno = 55; regno >= 24; regno--)
  527.       if (regs_ever_live[regno] && ! call_used_regs[regno])
  528.         {
  529.       if (big)
  530.         {
  531. #ifdef MOTOROLA
  532.           asm_fprintf (stream, "\tfpmovd -%d(%s,%Ra1.l), %s\n",
  533.                fpoffset + fsize,
  534.                reg_names[FRAME_POINTER_REGNUM],
  535.                reg_names[regno]);
  536. #else
  537.           asm_fprintf (stream, "\tfpmoved %s@(-%d,%Ra1:l), %s\n",
  538.                reg_names[FRAME_POINTER_REGNUM],
  539.                fpoffset + fsize, reg_names[regno]);
  540. #endif
  541.         }
  542.       else if (! frame_pointer_needed)
  543.         {
  544. #ifdef MOTOROLA
  545.           asm_fprintf (stream, "\tfpmovd (%Rsp)+,%s\n",
  546.                reg_names[regno]);
  547. #else
  548.           asm_fprintf (stream, "\tfpmoved %Rsp@+, %s\n",
  549.                reg_names[regno]);
  550. #endif
  551.         }
  552.       else
  553.         {
  554. #ifdef MOTOROLA
  555.           asm_fprintf (stream, "\tfpmovd -%d(%s), %s\n",
  556.                fpoffset + fsize,
  557.                reg_names[FRAME_POINTER_REGNUM],
  558.                reg_names[regno]);
  559. #else
  560.           asm_fprintf (stream, "\tfpmoved %s@(-%d), %s\n",
  561.                reg_names[FRAME_POINTER_REGNUM],
  562.                fpoffset + fsize, reg_names[regno]);
  563. #endif
  564.         }
  565.       fpoffset -= 8;
  566.     }
  567.   if (frame_pointer_needed)
  568. #ifndef MOTOROLA
  569.     if (TARGET_STACKEXTEND && current_function_calls_alloca)
  570.       asm_fprintf (stream, "\tjra ___unlk_%s_rts\n",
  571.                    reg_names[FRAME_POINTER_REGNUM]);
  572.       else
  573. #endif
  574.     fprintf (stream, "\tunlk %s\n",
  575.          reg_names[FRAME_POINTER_REGNUM]);
  576.   else if (fsize)
  577.     {
  578.       if (fsize + 4 < 0x8000)
  579.     {
  580.     /* asm_fprintf() cannot handle %. */
  581. #ifdef MOTOROLA
  582.       asm_fprintf (stream, "\tadd.w %0I%d,%Rsp\n", fsize + 4);
  583. #else
  584.       asm_fprintf (stream, "\taddw %0I%d,%Rsp\n", fsize + 4);
  585. #endif
  586.     }
  587.       else
  588.     {
  589.     /* asm_fprintf() cannot handle %. */
  590. #ifdef MOTOROLA
  591.       asm_fprintf (stream, "\tadd.l %0I%d,%Rsp\n", fsize + 4);
  592. #else
  593.       asm_fprintf (stream, "\taddl %0I%d,%Rsp\n", fsize + 4);
  594. #endif
  595.     }
  596.     }
  597. #ifdef EPILOGUE_EXTRA_TEST
  598.   EPILOGUE_EXTRA_TEST(stream);
  599. #endif
  600.   if (current_function_pops_args)
  601.     asm_fprintf (stream, "\trtd %0I%d\n", current_function_pops_args);
  602.   else
  603.     if (!TARGET_STACKEXTEND ||
  604.        !frame_pointer_needed || !current_function_calls_alloca)
  605.       fprintf (stream, "\trts\n");
  606. }
  607.  
  608. /* Similar to general_operand, but exclude stack_pointer_rtx.  */
  609.  
  610. int
  611. not_sp_operand (op, mode)
  612.      register rtx op;
  613.      enum machine_mode mode;
  614. {
  615.   return op != stack_pointer_rtx && general_operand (op, mode);
  616. }
  617.  
  618. /* Return TRUE if X is a valid comparison operator for the dbcc 
  619.    instruction.  
  620.  
  621.    Note it rejects floating point comparison operators.
  622.    (In the future we could use Fdbcc).
  623.  
  624.    It also rejects some comparisons when CC_NO_OVERFLOW is set.  */
  625.    
  626. int
  627. valid_dbcc_comparison_p (x, mode)
  628.      rtx x;
  629.      enum machine_mode mode;
  630. {
  631.   /* We could add support for these in the future */
  632.   if (cc_prev_status.flags & CC_IN_68881)
  633.     return 0;
  634.  
  635.   switch (GET_CODE (x))
  636.     {
  637.  
  638.       case EQ: case NE: case GTU: case LTU:
  639.       case GEU: case LEU:
  640.         return 1;
  641.  
  642.       /* Reject some when CC_NO_OVERFLOW is set.  This may be over
  643.          conservative */
  644.       case GT: case LT: case GE: case LE:
  645.         return ! (cc_prev_status.flags & CC_NO_OVERFLOW);
  646.       default:
  647.         return 0;
  648.     }
  649. }
  650.  
  651. /* Output a dbCC; jCC sequence.  Note we do not handle the 
  652.    floating point version of this sequence (Fdbcc).  We also
  653.    do not handle alternative conditions when CC_NO_OVERFLOW is
  654.    set.  It is assumed that valid_dbcc_comparison_p will kick
  655.    those out before we get here.  */
  656.  
  657. output_dbcc_and_branch (operands)
  658.      rtx *operands;
  659. {
  660.  
  661.   switch (GET_CODE (operands[3]))
  662.     {
  663.       case EQ:
  664. #ifdef MOTOROLA
  665.         output_asm_insn ("dbeq %0,%l1\n\tjbeq %l2", operands);
  666. #else
  667.         output_asm_insn ("dbeq %0,%l1\n\tjeq %l2", operands);
  668. #endif
  669.         break;
  670.  
  671.       case NE:
  672. #ifdef MOTOROLA
  673.         output_asm_insn ("dbne %0,%l1\n\tjbne %l2", operands);
  674. #else
  675.         output_asm_insn ("dbne %0,%l1\n\tjne %l2", operands);
  676. #endif
  677.         break;
  678.  
  679.       case GT:
  680. #ifdef MOTOROLA
  681.         output_asm_insn ("dbgt %0,%l1\n\tjbgt %l2", operands);
  682. #else
  683.         output_asm_insn ("dbgt %0,%l1\n\tjgt %l2", operands);
  684. #endif
  685.         break;
  686.  
  687.       case GTU:
  688. #ifdef MOTOROLA
  689.         output_asm_insn ("dbhi %0,%l1\n\tjbhi %l2", operands);
  690. #else
  691.         output_asm_insn ("dbhi %0,%l1\n\tjhi %l2", operands);
  692. #endif
  693.         break;
  694.  
  695.       case LT:
  696. #ifdef MOTOROLA
  697.         output_asm_insn ("dblt %0,%l1\n\tjblt %l2", operands);
  698. #else
  699.         output_asm_insn ("dblt %0,%l1\n\tjlt %l2", operands);
  700. #endif
  701.         break;
  702.  
  703.       case LTU:
  704. #ifdef MOTOROLA
  705.         output_asm_insn ("dbcs %0,%l1\n\tjbcs %l2", operands);
  706. #else
  707.         output_asm_insn ("dbcs %0,%l1\n\tjcs %l2", operands);
  708. #endif
  709.         break;
  710.  
  711.       case GE:
  712. #ifdef MOTOROLA
  713.         output_asm_insn ("dbge %0,%l1\n\tjbge %l2", operands);
  714. #else
  715.         output_asm_insn ("dbge %0,%l1\n\tjge %l2", operands);
  716. #endif
  717.         break;
  718.  
  719.       case GEU:
  720. #ifdef MOTOROLA
  721.         output_asm_insn ("dbcc %0,%l1\n\tjbcc %l2", operands);
  722. #else
  723.         output_asm_insn ("dbcc %0,%l1\n\tjcc %l2", operands);
  724. #endif
  725.         break;
  726.  
  727.       case LE:
  728. #ifdef MOTOROLA
  729.         output_asm_insn ("dble %0,%l1\n\tjble %l2", operands);
  730. #else
  731.         output_asm_insn ("dble %0,%l1\n\tjle %l2", operands);
  732. #endif
  733.         break;
  734.  
  735.       case LEU:
  736. #ifdef MOTOROLA
  737.         output_asm_insn ("dbls %0,%l1\n\tjbls %l2", operands);
  738. #else
  739.         output_asm_insn ("dbls %0,%l1\n\tjls %l2", operands);
  740. #endif
  741.         break;
  742.  
  743.       default:
  744.     abort ();
  745.     }
  746.  
  747.   /* If the decrement is to be done in SImode, then we have
  748.      to compensate for the fact that dbcc decrements in HImode. */
  749.   switch (GET_MODE (operands[0]))
  750.     {
  751.       case SImode:
  752. #ifdef MOTOROLA
  753.         output_asm_insn ("clr%.w %0\n\tsubq%.l %#1,%0\n\tjbpl %l1", operands);
  754. #else
  755.         output_asm_insn ("clr%.w %0\n\tsubq%.l %#1,%0\n\tjpl %l1", operands);
  756. #endif
  757.         break;
  758.  
  759.       case HImode:
  760.         break;
  761.  
  762.       default:
  763.         abort ();
  764.     }
  765. }
  766.  
  767. char *
  768. output_scc_di(op, operand1, operand2, dest)
  769.      rtx op;
  770.      rtx operand1;
  771.      rtx operand2;
  772.      rtx dest;
  773. {
  774.   rtx loperands[7];
  775.  
  776.   loperands[0] = operand1;
  777.   if (GET_CODE (operand1) == REG)
  778.     loperands[1] = gen_rtx (REG, SImode, REGNO (operand1) + 1);
  779.   else
  780.     loperands[1] = adj_offsettable_operand (operand1, 4);
  781.   if (operand2 != const0_rtx)
  782.     {
  783.       loperands[2] = operand2;
  784.       if (GET_CODE (operand2) == REG)
  785.     loperands[3] = gen_rtx (REG, SImode, REGNO (operand2) + 1);
  786.       else
  787.     loperands[3] = adj_offsettable_operand (operand2, 4);
  788.     }
  789.   loperands[4] = gen_label_rtx();
  790.   if (operand2 != const0_rtx)
  791. #ifdef MOTOROLA
  792.     output_asm_insn ("cmp%.l %0,%2\n\tjbne %l4\n\tcmp%.l %1,%3", loperands);
  793. #else
  794.     output_asm_insn ("cmp%.l %0,%2\n\tjne %l4\n\tcmp%.l %1,%3", loperands);
  795. #endif
  796.   else
  797. #ifdef MOTOROLA
  798.     output_asm_insn ("tst%.l %0\n\tjbne %l4\n\ttst%.l %1", loperands);
  799. #else
  800.     output_asm_insn ("tst%.l %0\n\tjne %l4\n\ttst%.l %1", loperands);
  801. #endif
  802.   loperands[5] = dest;
  803.   
  804.   switch (GET_CODE (op))
  805.     {
  806.       case EQ:
  807.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  808.                     CODE_LABEL_NUMBER (loperands[4]));
  809.         output_asm_insn ("seq %5", loperands);
  810.         break;
  811.  
  812.       case NE:
  813.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  814.                     CODE_LABEL_NUMBER (loperands[4]));
  815.         output_asm_insn ("sne %5", loperands);
  816.         break;
  817.  
  818.       case GT:
  819.         loperands[6] = gen_label_rtx();
  820. #ifdef MOTOROLA
  821.         output_asm_insn ("shi %5\n\tjbra %l6", loperands);
  822. #else
  823.         output_asm_insn ("shi %5\n\tjra %l6", loperands);
  824. #endif
  825.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  826.                     CODE_LABEL_NUMBER (loperands[4]));
  827.         output_asm_insn ("sgt %5", loperands);
  828.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  829.                     CODE_LABEL_NUMBER (loperands[6]));
  830.         break;
  831.  
  832.       case GTU:
  833.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  834.                     CODE_LABEL_NUMBER (loperands[4]));
  835.         output_asm_insn ("shi %5", loperands);
  836.         break;
  837.  
  838.       case LT:
  839.         loperands[6] = gen_label_rtx();
  840. #ifdef MOTOROLA
  841.         output_asm_insn ("scs %5\n\tjbra %l6", loperands);
  842. #else
  843.         output_asm_insn ("scs %5\n\tjra %l6", loperands);
  844. #endif
  845.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  846.                     CODE_LABEL_NUMBER (loperands[4]));
  847.         output_asm_insn ("slt %5", loperands);
  848.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  849.                     CODE_LABEL_NUMBER (loperands[6]));
  850.         break;
  851.  
  852.       case LTU:
  853.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  854.                     CODE_LABEL_NUMBER (loperands[4]));
  855.         output_asm_insn ("scs %5", loperands);
  856.         break;
  857.  
  858.       case GE:
  859.         loperands[6] = gen_label_rtx();
  860. #ifdef MOTOROLA
  861.         output_asm_insn ("scc %5\n\tjbra %l6", loperands);
  862. #else
  863.         output_asm_insn ("scc %5\n\tjra %l6", loperands);
  864. #endif
  865.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  866.                     CODE_LABEL_NUMBER (loperands[4]));
  867.         output_asm_insn ("sge %5", loperands);
  868.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  869.                     CODE_LABEL_NUMBER (loperands[6]));
  870.         break;
  871.  
  872.       case GEU:
  873.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  874.                     CODE_LABEL_NUMBER (loperands[4]));
  875.         output_asm_insn ("scc %5", loperands);
  876.         break;
  877.  
  878.       case LE:
  879.         loperands[6] = gen_label_rtx();
  880. #ifdef MOTOROLA
  881.         output_asm_insn ("sls %5\n\tjbra %l6", loperands);
  882. #else
  883.         output_asm_insn ("sls %5\n\tjra %l6", loperands);
  884. #endif
  885.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  886.                     CODE_LABEL_NUMBER (loperands[4]));
  887.         output_asm_insn ("sle %5", loperands);
  888.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  889.                     CODE_LABEL_NUMBER (loperands[6]));
  890.         break;
  891.  
  892.       case LEU:
  893.         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
  894.                     CODE_LABEL_NUMBER (loperands[4]));
  895.         output_asm_insn ("sls %5", loperands);
  896.         break;
  897.  
  898.       default:
  899.     abort ();
  900.     }
  901.   return "";
  902. }
  903.  
  904. char *
  905. output_btst (operands, countop, dataop, insn, signpos)
  906.      rtx *operands;
  907.      rtx countop, dataop;
  908.      rtx insn;
  909.      int signpos;
  910. {
  911.   operands[0] = countop;
  912.   operands[1] = dataop;
  913.  
  914.   if (GET_CODE (countop) == CONST_INT)
  915.     {
  916.       register int count = INTVAL (countop);
  917.       /* If COUNT is bigger than size of storage unit in use,
  918.      advance to the containing unit of same size.  */
  919.       if (count > signpos)
  920.     {
  921.       int offset = (count & ~signpos) / 8;
  922.       count = count & signpos;
  923.       operands[1] = dataop = adj_offsettable_operand (dataop, offset);
  924.     }
  925.       if (count == signpos)
  926.     cc_status.flags = CC_NOT_POSITIVE | CC_Z_IN_NOT_N;
  927.       else
  928.     cc_status.flags = CC_NOT_NEGATIVE | CC_Z_IN_NOT_N;
  929.  
  930.       /* These three statements used to use next_insns_test_no...
  931.      but it appears that this should do the same job.  */
  932.       if (count == 31
  933.       && next_insn_tests_no_inequality (insn))
  934.     return "tst%.l %1";
  935.       if (count == 15
  936.       && next_insn_tests_no_inequality (insn))
  937.     return "tst%.w %1";
  938.       if (count == 7
  939.       && next_insn_tests_no_inequality (insn))
  940.     return "tst%.b %1";
  941.  
  942.       cc_status.flags = CC_NOT_NEGATIVE;
  943.     }
  944.   return "btst %0,%1";
  945. }
  946.  
  947. /* Returns 1 if OP is either a symbol reference or a sum of a symbol
  948.    reference and a constant.  */
  949.  
  950. int
  951. symbolic_operand (op, mode)
  952.      register rtx op;
  953.      enum machine_mode mode;
  954. {
  955.   switch (GET_CODE (op))
  956.     {
  957.     case SYMBOL_REF:
  958.     case LABEL_REF:
  959.       return 1;
  960.  
  961.     case CONST:
  962.       op = XEXP (op, 0);
  963.       return ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF
  964.            || GET_CODE (XEXP (op, 0)) == LABEL_REF)
  965.           && GET_CODE (XEXP (op, 1)) == CONST_INT);
  966.  
  967. #if 0 /* Deleted, with corresponding change in m68k.h,
  968.      so as to fit the specs.  No CONST_DOUBLE is ever symbolic.  */
  969.     case CONST_DOUBLE:
  970.       return GET_MODE (op) == mode;
  971. #endif
  972.  
  973.     default:
  974.       return 0;
  975.     }
  976. }
  977.  
  978. /* Check for sign_extend or zero_extend.  Used for bit-count operands. */
  979.  
  980. int
  981. extend_operator(x, mode)
  982.      rtx x;
  983.      enum machine_mode mode;
  984. {
  985.     if (mode != VOIDmode && GET_MODE(x) != mode)
  986.     return 0;
  987.     switch (GET_CODE(x))
  988.     {
  989.     case SIGN_EXTEND :
  990.     case ZERO_EXTEND :
  991.         return 1;
  992.     default :
  993.         return 0;
  994.     }
  995. }
  996.  
  997.  
  998. /* Legitimize PIC addresses.  If the address is already
  999.    position-independent, we return ORIG.  Newly generated
  1000.    position-independent addresses go to REG.  If we need more
  1001.    than one register, we lose.  
  1002.  
  1003.    An address is legitimized by making an indirect reference
  1004.    through the Global Offset Table with the name of the symbol
  1005.    used as an offset.  
  1006.  
  1007.    The assembler and linker are responsible for placing the 
  1008.    address of the symbol in the GOT.  The function prologue
  1009.    is responsible for initializing a5 to the starting address
  1010.    of the GOT.
  1011.  
  1012.    The assembler is also responsible for translating a symbol name
  1013.    into a constant displacement from the start of the GOT.  
  1014.  
  1015.    A quick example may make things a little clearer:
  1016.  
  1017.    When not generating PIC code to store the value 12345 into _foo
  1018.    we would generate the following code:
  1019.  
  1020.     movel #12345, _foo
  1021.  
  1022.    When generating PIC two transformations are made.  First, the compiler
  1023.    loads the address of foo into a register.  So the first transformation makes:
  1024.  
  1025.     lea    _foo, a0
  1026.     movel   #12345, a0@
  1027.  
  1028.    The code in movsi will intercept the lea instruction and call this
  1029.    routine which will transform the instructions into:
  1030.  
  1031.     movel   a5@(_foo:w), a0
  1032.     movel   #12345, a0@
  1033.    
  1034.  
  1035.    That (in a nutshell) is how *all* symbol and label references are 
  1036.    handled.  */
  1037.  
  1038. rtx
  1039. legitimize_pic_address (orig, mode, reg)
  1040.      rtx orig, reg;
  1041.      enum machine_mode mode;
  1042. {
  1043.   rtx pic_ref = orig;
  1044.  
  1045.   /* First handle a simple SYMBOL_REF or LABEL_REF */
  1046.   if (GET_CODE (orig) == SYMBOL_REF || GET_CODE (orig) == LABEL_REF)
  1047.     {
  1048. #ifdef LEGITIMATE_BASEREL_OPERAND_P
  1049.   if (LEGITIMATE_BASEREL_OPERAND_P (orig))
  1050.     return orig;
  1051. #endif
  1052.  
  1053.       if (reg == 0)
  1054.     abort ();
  1055.  
  1056.       if (flag_pic >= 3)
  1057.     pic_ref = gen_rtx (PLUS, Pmode, pic_offset_table_rtx, orig);
  1058.       else
  1059.         pic_ref = gen_rtx (MEM, Pmode,
  1060.                gen_rtx (PLUS, Pmode,
  1061.                     pic_offset_table_rtx, orig));
  1062.       current_function_uses_pic_offset_table = 1;
  1063.       RTX_UNCHANGING_P (pic_ref) = 1;
  1064.       emit_move_insn (reg, pic_ref);
  1065.       return reg;
  1066.     }
  1067.   else if (GET_CODE (orig) == CONST)
  1068.     {
  1069.       rtx base, offset;
  1070.  
  1071.       /* Make sure this is CONST has not already been legitimized */
  1072.       if (GET_CODE (XEXP (orig, 0)) == PLUS
  1073.       && XEXP (XEXP (orig, 0), 0) == pic_offset_table_rtx)
  1074.     return orig;
  1075.  
  1076.       if (reg == 0)
  1077.     abort ();
  1078.  
  1079.       /* legitimize both operands of the PLUS */
  1080.       if (GET_CODE (XEXP (orig, 0)) == PLUS)
  1081.     {
  1082.       base = legitimize_pic_address (XEXP (XEXP (orig, 0), 0), Pmode, reg);
  1083.       orig = legitimize_pic_address (XEXP (XEXP (orig, 0), 1), Pmode,
  1084.                      base == reg ? 0 : reg);
  1085.     }
  1086.       else abort ();
  1087.  
  1088.       if (GET_CODE (orig) == CONST_INT)
  1089.     return plus_constant_for_output (base, INTVAL (orig));
  1090.       pic_ref = gen_rtx (PLUS, Pmode, base, orig);
  1091.       /* Likewise, should we set special REG_NOTEs here?  */
  1092.     }
  1093.   return pic_ref;
  1094. }
  1095.  
  1096.  
  1097. typedef enum { MOVL, SWAP, NEGW, NOTW, NOTB, MOVQ } CONST_METHOD;
  1098.  
  1099. use_movq (i)
  1100.      int i;
  1101. {
  1102.   return (i >= -128 && i <= 127);
  1103. }
  1104.  
  1105. CONST_METHOD
  1106. const_method (constant)
  1107.      rtx constant;
  1108. {
  1109.   int i;
  1110.   unsigned u;
  1111.  
  1112.   i = INTVAL (constant);
  1113.   if (use_movq (i))
  1114.     return MOVQ;
  1115.   /* if -256 < N < 256 but N is not in range for a moveq
  1116.      N^ff will be, so use moveq #N^ff, dreg; not.b dreg. */
  1117.   if (use_movq (i ^ 0xff))
  1118.     return NOTB;
  1119.   /* Likewise, try with not.w */
  1120.   if (use_movq (i ^ 0xffff))
  1121.     return NOTW;
  1122.   /* This is the only value where neg.w is useful */
  1123.   if (i == -65408)
  1124.     return NEGW;
  1125.   /* Try also with swap */
  1126.   u = i;
  1127.   if (use_movq ((u >> 16) | (u << 16)))
  1128.     return SWAP;
  1129.   /* Otherwise, use move.l */
  1130.   return MOVL;
  1131. }
  1132.  
  1133. const_int_cost (constant)
  1134.      rtx constant;
  1135. {
  1136.   switch (const_method (constant))
  1137.     {
  1138.       case MOVQ :
  1139.       /* Constants between -128 and 127 are cheap due to moveq */
  1140.     return 0;
  1141.       case NOTB :
  1142.       case NOTW :
  1143.       case NEGW :
  1144.       case SWAP :
  1145.       /* Constants easily generated by moveq + not.b/not.w/neg.w/swap  */
  1146.         return 1;
  1147.       case MOVL :
  1148.     return 2;
  1149.       default :
  1150.         abort ();
  1151.     }
  1152. }
  1153.  
  1154. char *
  1155. output_move_const_into_data_reg (operands)
  1156.      rtx *operands;
  1157. {
  1158.   int i;
  1159.  
  1160.   i = INTVAL (operands[1]);
  1161.   switch (const_method (operands[1]))
  1162.     {
  1163.     case MOVQ :
  1164. #if defined (MOTOROLA) && !defined (CRDS)
  1165.       return "moveq%.l %1,%0";
  1166. #else
  1167.       return "moveq %1,%0";
  1168. #endif
  1169.     case NOTB :
  1170.       operands[1] = gen_rtx (CONST_INT, VOIDmode, i ^ 0xff);
  1171. #if defined (MOTOROLA) && !defined (CRDS)
  1172.       return "moveq%.l %1,%0\n\tnot%.b %0";
  1173. #else
  1174.       return "moveq %1,%0\n\tnot%.b %0";
  1175. #endif     
  1176.     case NOTW :
  1177.       operands[1] = gen_rtx (CONST_INT, VOIDmode, i ^ 0xffff);
  1178. #if defined (MOTOROLA) && !defined (CRDS)
  1179.       return "moveq%.l %1,%0\n\tnot%.w %0";
  1180. #else
  1181.       return "moveq %1,%0\n\tnot%.w %0";
  1182. #endif     
  1183.     case NEGW :
  1184. #if defined (MOTOROLA) && !defined (CRDS)
  1185.       return "moveq%.l %#-128,%0\n\tneg%.w %0";
  1186. #else
  1187.       return "moveq %#-128,%0\n\tneg%.w %0";
  1188. #endif     
  1189.     case SWAP :
  1190.       {
  1191.     unsigned u = i;
  1192.  
  1193.     operands[1] = gen_rtx (CONST_INT, VOIDmode, (u << 16) | (u >> 16));
  1194. #if defined (MOTOROLA) && !defined (CRDS)
  1195.     return "moveq%.l %1,%0\n\tswap %0";
  1196. #else
  1197.     return "moveq %1,%0\n\tswap %0";
  1198. #endif     
  1199.       }
  1200.     case MOVL :
  1201.     return "move%.l %1,%0";
  1202.     default :
  1203.     abort ();
  1204.     }
  1205. }
  1206.  
  1207. /* Return the best assembler insn template
  1208.    for moving operands[1] into operands[0] as a fullword.  */
  1209.  
  1210. static char *
  1211. singlemove_string (operands)
  1212.      rtx *operands;
  1213. {
  1214. #ifdef SUPPORT_SUN_FPA
  1215.   if (FPA_REG_P (operands[0]) || FPA_REG_P (operands[1]))
  1216.     return "fpmoves %1,%0";
  1217. #endif
  1218.   if (DATA_REG_P (operands[0])
  1219.       && GET_CODE (operands[1]) == CONST_INT)
  1220.       return output_move_const_into_data_reg (operands);
  1221.   if (operands[1] != const0_rtx)
  1222.     return "move%.l %1,%0";
  1223.   if (! ADDRESS_REG_P (operands[0]))
  1224.     return "clr%.l %0";
  1225.   return "sub%.l %0,%0";
  1226. }
  1227.  
  1228.  
  1229. /* Output assembler code to perform a doubleword move insn
  1230.    with operands OPERANDS.  */
  1231.  
  1232. char *
  1233. output_move_double (operands)
  1234.      rtx *operands;
  1235. {
  1236.   enum
  1237.     {
  1238.       REGOP, OFFSOP, MEMOP, PUSHOP, POPOP, CNSTOP, RNDOP
  1239.     } optype0, optype1;
  1240.   rtx latehalf[2];
  1241.   rtx middlehalf[2];
  1242.   rtx xops[2];
  1243.   rtx addreg0 = 0, addreg1 = 0;
  1244.   int dest_overlapped_low = 0;
  1245.   int size = GET_MODE_SIZE (GET_MODE (operands[0]));
  1246.  
  1247.   middlehalf[0] = 0;
  1248.   middlehalf[1] = 0;
  1249.  
  1250.   /* First classify both operands.  */
  1251.  
  1252.   if (REG_P (operands[0]))
  1253.     optype0 = REGOP;
  1254.   else if (offsettable_memref_p (operands[0]))
  1255.     optype0 = OFFSOP;
  1256.   else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
  1257.     optype0 = POPOP;
  1258.   else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
  1259.     optype0 = PUSHOP;
  1260.   else if (GET_CODE (operands[0]) == MEM)
  1261.     optype0 = MEMOP;
  1262.   else
  1263.     optype0 = RNDOP;
  1264.  
  1265.   if (REG_P (operands[1]))
  1266.     optype1 = REGOP;
  1267.   else if (CONSTANT_P (operands[1]))
  1268.     optype1 = CNSTOP;
  1269.   else if (offsettable_memref_p (operands[1]))
  1270.     optype1 = OFFSOP;
  1271.   else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC)
  1272.     optype1 = POPOP;
  1273.   else if (GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
  1274.     optype1 = PUSHOP;
  1275.   else if (GET_CODE (operands[1]) == MEM)
  1276.     optype1 = MEMOP;
  1277.   else
  1278.     optype1 = RNDOP;
  1279.  
  1280.   /* Check for the cases that the operand constraints are not
  1281.      supposed to allow to happen.  Abort if we get one,
  1282.      because generating code for these cases is painful.  */
  1283.  
  1284.   if (optype0 == RNDOP || optype1 == RNDOP)
  1285.     abort ();
  1286.  
  1287.   /* If one operand is decrementing and one is incrementing
  1288.      decrement the former register explicitly
  1289.      and change that operand into ordinary indexing.  */
  1290.  
  1291.   if (optype0 == PUSHOP && optype1 == POPOP)
  1292.     {
  1293.       operands[0] = XEXP (XEXP (operands[0], 0), 0);
  1294.       if (size == 12)
  1295.         output_asm_insn ("sub%.l %#12,%0", operands);
  1296.       else
  1297.         output_asm_insn ("subq%.l %#8,%0", operands);
  1298.       if (GET_MODE (operands[1]) == XFmode)
  1299.     operands[0] = gen_rtx (MEM, XFmode, operands[0]);
  1300.       else if (GET_MODE (operands[0]) == DFmode)
  1301.     operands[0] = gen_rtx (MEM, DFmode, operands[0]);
  1302.       else
  1303.     operands[0] = gen_rtx (MEM, DImode, operands[0]);
  1304.       optype0 = OFFSOP;
  1305.     }
  1306.   if (optype0 == POPOP && optype1 == PUSHOP)
  1307.     {
  1308.       operands[1] = XEXP (XEXP (operands[1], 0), 0);
  1309.       if (size == 12)
  1310.         output_asm_insn ("sub%.l %#12,%1", operands);
  1311.       else
  1312.         output_asm_insn ("subq%.l %#8,%1", operands);
  1313.       if (GET_MODE (operands[1]) == XFmode)
  1314.     operands[1] = gen_rtx (MEM, XFmode, operands[1]);
  1315.       else if (GET_MODE (operands[1]) == DFmode)
  1316.     operands[1] = gen_rtx (MEM, DFmode, operands[1]);
  1317.       else
  1318.     operands[1] = gen_rtx (MEM, DImode, operands[1]);
  1319.       optype1 = OFFSOP;
  1320.     }
  1321.  
  1322.   /* If an operand is an unoffsettable memory ref, find a register
  1323.      we can increment temporarily to make it refer to the second word.  */
  1324.  
  1325.   if (optype0 == MEMOP)
  1326.     addreg0 = find_addr_reg (XEXP (operands[0], 0));
  1327.  
  1328.   if (optype1 == MEMOP)
  1329.     addreg1 = find_addr_reg (XEXP (operands[1], 0));
  1330.  
  1331.   /* Ok, we can do one word at a time.
  1332.      Normally we do the low-numbered word first,
  1333.      but if either operand is autodecrementing then we
  1334.      do the high-numbered word first.
  1335.  
  1336.      In either case, set up in LATEHALF the operands to use
  1337.      for the high-numbered word and in some cases alter the
  1338.      operands in OPERANDS to be suitable for the low-numbered word.  */
  1339.  
  1340.   if (size == 12)
  1341.     {
  1342.       if (optype0 == REGOP)
  1343.     {
  1344.       latehalf[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 2);
  1345.       middlehalf[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1346.     }
  1347.       else if (optype0 == OFFSOP)
  1348.     {
  1349.       middlehalf[0] = adj_offsettable_operand (operands[0], 4);
  1350.       latehalf[0] = adj_offsettable_operand (operands[0], size - 4);
  1351.     }
  1352.       else
  1353.     {
  1354.       middlehalf[0] = operands[0];
  1355.       latehalf[0] = operands[0];
  1356.     }
  1357.  
  1358.       if (optype1 == REGOP)
  1359.     {
  1360.       latehalf[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 2);
  1361.       middlehalf[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  1362.     }
  1363.       else if (optype1 == OFFSOP)
  1364.     {
  1365.       middlehalf[1] = adj_offsettable_operand (operands[1], 4);
  1366.       latehalf[1] = adj_offsettable_operand (operands[1], size - 4);
  1367.     }
  1368.       else if (optype1 == CNSTOP)
  1369.     {
  1370.       if (GET_CODE (operands[1]) == CONST_DOUBLE)
  1371.         {
  1372.           REAL_VALUE_TYPE r;
  1373.           long l[3];
  1374.  
  1375.           REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
  1376.           REAL_VALUE_TO_TARGET_LONG_DOUBLE (r, l);
  1377.           operands[1] = GEN_INT (l[0]);
  1378.           middlehalf[1] = GEN_INT (l[1]);
  1379.           latehalf[1] = GEN_INT (l[2]);
  1380.         }
  1381.       else if (CONSTANT_P (operands[1]))
  1382.         {
  1383.           /* actually, no non-CONST_DOUBLE constant should ever
  1384.          appear here.  */
  1385.           abort ();
  1386.           if (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) < 0)
  1387.         latehalf[1] = constm1_rtx;
  1388.           else
  1389.         latehalf[1] = const0_rtx;
  1390.         }
  1391.     }
  1392.       else
  1393.     {
  1394.       middlehalf[1] = operands[1];
  1395.       latehalf[1] = operands[1];
  1396.     }
  1397.     }
  1398.   else
  1399.     /* size is not 12: */
  1400.     {
  1401.       if (optype0 == REGOP)
  1402.     latehalf[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1403.       else if (optype0 == OFFSOP)
  1404.     latehalf[0] = adj_offsettable_operand (operands[0], size - 4);
  1405.       else
  1406.     latehalf[0] = operands[0];
  1407.  
  1408.       if (optype1 == REGOP)
  1409.     latehalf[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  1410.       else if (optype1 == OFFSOP)
  1411.     latehalf[1] = adj_offsettable_operand (operands[1], size - 4);
  1412.       else if (optype1 == CNSTOP)
  1413.     split_double (operands[1], &operands[1], &latehalf[1]);
  1414.       else
  1415.     latehalf[1] = operands[1];
  1416.     }
  1417.  
  1418.   /* If insn is effectively movd N(sp),-(sp) then we will do the
  1419.      high word first.  We should use the adjusted operand 1 (which is N+4(sp))
  1420.      for the low word as well, to compensate for the first decrement of sp.  */
  1421.   if (optype0 == PUSHOP
  1422.       && REGNO (XEXP (XEXP (operands[0], 0), 0)) == STACK_POINTER_REGNUM
  1423.       && reg_overlap_mentioned_p (stack_pointer_rtx, operands[1]))
  1424.     operands[1] = middlehalf[1] = latehalf[1];
  1425.  
  1426.   /* For (set (reg:DI N) (mem:DI ... (reg:SI N) ...)),
  1427.      if the upper part of reg N does not appear in the MEM, arrange to
  1428.      emit the move late-half first.  Otherwise, compute the MEM address
  1429.      into the upper part of N and use that as a pointer to the memory
  1430.      operand.  */
  1431.   if (optype0 == REGOP
  1432.       && (optype1 == OFFSOP || optype1 == MEMOP))
  1433.     {
  1434.       rtx testlow = gen_rtx (REG, SImode, REGNO (operands[0]));
  1435.  
  1436.       if (reg_overlap_mentioned_p (testlow, XEXP (operands[1], 0))
  1437.       && reg_overlap_mentioned_p (latehalf[0], XEXP (operands[1], 0)))
  1438.     {
  1439.       /* If both halves of dest are used in the src memory address,
  1440.          compute the address into latehalf of dest.
  1441.          Note that this can't happen if the dest is two data regs.  */
  1442. compadr:
  1443.       xops[0] = latehalf[0];
  1444.       xops[1] = XEXP (operands[1], 0);
  1445.       output_asm_insn ("lea %a1,%0", xops);
  1446.       if( GET_MODE (operands[1]) == XFmode )
  1447.         {
  1448.           operands[1] = gen_rtx (MEM, XFmode, latehalf[0]);
  1449.           middlehalf[1] = adj_offsettable_operand (operands[1], size-8);
  1450.           latehalf[1] = adj_offsettable_operand (operands[1], size-4);
  1451.         }
  1452.       else
  1453.         {
  1454.           operands[1] = gen_rtx (MEM, DImode, latehalf[0]);
  1455.           latehalf[1] = adj_offsettable_operand (operands[1], size-4);
  1456.         }
  1457.     }
  1458.       else if (size == 12
  1459.            && reg_overlap_mentioned_p (middlehalf[0],
  1460.                        XEXP (operands[1], 0)))
  1461.     {
  1462.       /* Check for two regs used by both source and dest.
  1463.          Note that this can't happen if the dest is all data regs.
  1464.          It can happen if the dest is d6, d7, a0.
  1465.          But in that case, latehalf is an addr reg, so
  1466.          the code at compadr does ok.  */
  1467.  
  1468.       if (reg_overlap_mentioned_p (testlow, XEXP (operands[1], 0))
  1469.           || reg_overlap_mentioned_p (latehalf[0], XEXP (operands[1], 0)))
  1470.         goto compadr;
  1471.  
  1472.       /* JRV says this can't happen: */
  1473.       if (addreg0 || addreg1)
  1474.         abort ();
  1475.  
  1476.       /* Only the middle reg conflicts; simply put it last. */
  1477.       output_asm_insn (singlemove_string (operands), operands);
  1478.       output_asm_insn (singlemove_string (latehalf), latehalf);
  1479.       output_asm_insn (singlemove_string (middlehalf), middlehalf);
  1480.       return "";
  1481.     }
  1482.       else if (reg_overlap_mentioned_p (testlow, XEXP (operands[1], 0)))
  1483.     /* If the low half of dest is mentioned in the source memory
  1484.        address, the arrange to emit the move late half first.  */
  1485.     dest_overlapped_low = 1;
  1486.     }
  1487.  
  1488.   /* If one or both operands autodecrementing,
  1489.      do the two words, high-numbered first.  */
  1490.  
  1491.   /* Likewise,  the first move would clobber the source of the second one,
  1492.      do them in the other order.  This happens only for registers;
  1493.      such overlap can't happen in memory unless the user explicitly
  1494.      sets it up, and that is an undefined circumstance.  */
  1495.  
  1496.   if (optype0 == PUSHOP || optype1 == PUSHOP
  1497.       || (optype0 == REGOP && optype1 == REGOP
  1498.       && ((middlehalf[1] && REGNO (operands[0]) == REGNO (middlehalf[1]))
  1499.           || REGNO (operands[0]) == REGNO (latehalf[1])))
  1500.       || dest_overlapped_low)
  1501.     {
  1502.       /* Make any unoffsettable addresses point at high-numbered word.  */
  1503.       if (addreg0)
  1504.     {
  1505.       if (size == 12)
  1506.         output_asm_insn ("addq%.l %#8,%0", &addreg0);
  1507.       else
  1508.         output_asm_insn ("addq%.l %#4,%0", &addreg0);
  1509.     }
  1510.       if (addreg1)
  1511.     {
  1512.       if (size == 12)
  1513.         output_asm_insn ("addq%.l %#8,%0", &addreg1);
  1514.       else
  1515.         output_asm_insn ("addq%.l %#4,%0", &addreg1);
  1516.     }
  1517.  
  1518.       /* Do that word.  */
  1519.       output_asm_insn (singlemove_string (latehalf), latehalf);
  1520.  
  1521.       /* Undo the adds we just did.  */
  1522.       if (addreg0)
  1523.     output_asm_insn ("subq%.l %#4,%0", &addreg0);
  1524.       if (addreg1)
  1525.     output_asm_insn ("subq%.l %#4,%0", &addreg1);
  1526.  
  1527.       if (size == 12)
  1528.     {
  1529.       output_asm_insn (singlemove_string (middlehalf), middlehalf);
  1530.       if (addreg0)
  1531.         output_asm_insn ("subq%.l %#4,%0", &addreg0);
  1532.       if (addreg1)
  1533.         output_asm_insn ("subq%.l %#4,%0", &addreg1);
  1534.     }
  1535.  
  1536.       /* Do low-numbered word.  */
  1537.       return singlemove_string (operands);
  1538.     }
  1539.  
  1540.   /* Normal case: do the two words, low-numbered first.  */
  1541.  
  1542.   output_asm_insn (singlemove_string (operands), operands);
  1543.  
  1544.   /* Do the middle one of the three words for long double */
  1545.   if (size == 12)
  1546.     {
  1547.       if (addreg0)
  1548.     output_asm_insn ("addq%.l %#4,%0", &addreg0);
  1549.       if (addreg1)
  1550.     output_asm_insn ("addq%.l %#4,%0", &addreg1);
  1551.  
  1552.       output_asm_insn (singlemove_string (middlehalf), middlehalf);
  1553.     }
  1554.  
  1555.   /* Make any unoffsettable addresses point at high-numbered word.  */
  1556.   if (addreg0)
  1557.     output_asm_insn ("addq%.l %#4,%0", &addreg0);
  1558.   if (addreg1)
  1559.     output_asm_insn ("addq%.l %#4,%0", &addreg1);
  1560.  
  1561.   /* Do that word.  */
  1562.   output_asm_insn (singlemove_string (latehalf), latehalf);
  1563.  
  1564.   /* Undo the adds we just did.  */
  1565.   if (addreg0)
  1566.     {
  1567.       if (size == 12)
  1568.         output_asm_insn ("subq%.l %#8,%0", &addreg0);
  1569.       else
  1570.         output_asm_insn ("subq%.l %#4,%0", &addreg0);
  1571.     }
  1572.   if (addreg1)
  1573.     {
  1574.       if (size == 12)
  1575.         output_asm_insn ("subq%.l %#8,%0", &addreg1);
  1576.       else
  1577.         output_asm_insn ("subq%.l %#4,%0", &addreg1);
  1578.     }
  1579.  
  1580.   return "";
  1581. }
  1582.  
  1583. /* Return a REG that occurs in ADDR with coefficient 1.
  1584.    ADDR can be effectively incremented by incrementing REG.  */
  1585.  
  1586. static rtx
  1587. find_addr_reg (addr)
  1588.      rtx addr;
  1589. {
  1590.   while (GET_CODE (addr) == PLUS)
  1591.     {
  1592.       if (GET_CODE (XEXP (addr, 0)) == REG)
  1593.     addr = XEXP (addr, 0);
  1594.       else if (GET_CODE (XEXP (addr, 1)) == REG)
  1595.     addr = XEXP (addr, 1);
  1596.       else if (CONSTANT_P (XEXP (addr, 0)))
  1597.     addr = XEXP (addr, 1);
  1598.       else if (CONSTANT_P (XEXP (addr, 1)))
  1599.     addr = XEXP (addr, 0);
  1600.       else
  1601.     abort ();
  1602.     }
  1603.   if (GET_CODE (addr) == REG)
  1604.     return addr;
  1605.   abort ();
  1606. }
  1607.  
  1608. /* Store in cc_status the expressions that the condition codes will
  1609.    describe after execution of an instruction whose pattern is EXP.
  1610.    Do not alter them if the instruction would not alter the cc's.  */
  1611.  
  1612. /* On the 68000, all the insns to store in an address register fail to
  1613.    set the cc's.  However, in some cases these instructions can make it
  1614.    possibly invalid to use the saved cc's.  In those cases we clear out
  1615.    some or all of the saved cc's so they won't be used.  */
  1616.  
  1617. notice_update_cc (exp, insn)
  1618.      rtx exp;
  1619.      rtx insn;
  1620. {
  1621.   /* If the cc is being set from the fpa and the expression is not an
  1622.      explicit floating point test instruction (which has code to deal with
  1623.      this), reinit the CC.  */
  1624.   if (((cc_status.value1 && FPA_REG_P (cc_status.value1))
  1625.        || (cc_status.value2 && FPA_REG_P (cc_status.value2)))
  1626.       && !(GET_CODE (exp) == PARALLEL
  1627.        && GET_CODE (XVECEXP (exp, 0, 0)) == SET
  1628.        && XEXP (XVECEXP (exp, 0, 0), 0) == cc0_rtx))
  1629.     {
  1630.       CC_STATUS_INIT; 
  1631.     }
  1632.   else if (GET_CODE (exp) == SET)
  1633.     {
  1634.       if (GET_CODE (SET_SRC (exp)) == CALL)
  1635.     {
  1636.       CC_STATUS_INIT; 
  1637.     }
  1638.       else if (ADDRESS_REG_P (SET_DEST (exp)))
  1639.     {
  1640.       if (cc_status.value1
  1641.           && reg_overlap_mentioned_p (SET_DEST (exp), cc_status.value1))
  1642.         cc_status.value1 = 0;
  1643.       if (cc_status.value2
  1644.           && reg_overlap_mentioned_p (SET_DEST (exp), cc_status.value2))
  1645.         cc_status.value2 = 0; 
  1646.     }
  1647.       else if (!FP_REG_P (SET_DEST (exp))
  1648.            && SET_DEST (exp) != cc0_rtx
  1649.            && (FP_REG_P (SET_SRC (exp))
  1650.            || GET_CODE (SET_SRC (exp)) == FIX
  1651.            || GET_CODE (SET_SRC (exp)) == FLOAT_TRUNCATE
  1652.            || GET_CODE (SET_SRC (exp)) == FLOAT_EXTEND))
  1653.     {
  1654.       CC_STATUS_INIT; 
  1655.     }
  1656.       /* A pair of move insns doesn't produce a useful overall cc.  */
  1657.       else if (!FP_REG_P (SET_DEST (exp))
  1658.            && !FP_REG_P (SET_SRC (exp))
  1659.            && GET_MODE_SIZE (GET_MODE (SET_SRC (exp))) > 4
  1660.            && (GET_CODE (SET_SRC (exp)) == REG
  1661.            || GET_CODE (SET_SRC (exp)) == MEM
  1662.            || GET_CODE (SET_SRC (exp)) == CONST_DOUBLE))
  1663.     {
  1664.       CC_STATUS_INIT; 
  1665.     }
  1666.       else if (GET_CODE (SET_SRC (exp)) == CALL)
  1667.     {
  1668.       CC_STATUS_INIT; 
  1669.     }
  1670.       else if (XEXP (exp, 0) != pc_rtx)
  1671.     {
  1672.       cc_status.flags = 0;
  1673.       cc_status.value1 = XEXP (exp, 0);
  1674.       cc_status.value2 = XEXP (exp, 1);
  1675.     }
  1676.     }
  1677.   else if (GET_CODE (exp) == PARALLEL
  1678.        && GET_CODE (XVECEXP (exp, 0, 0)) == SET)
  1679.     {
  1680.       if (ADDRESS_REG_P (XEXP (XVECEXP (exp, 0, 0), 0)))
  1681.     CC_STATUS_INIT;
  1682.       else if (XEXP (XVECEXP (exp, 0, 0), 0) != pc_rtx)
  1683.     {
  1684.       cc_status.flags = 0;
  1685.       cc_status.value1 = XEXP (XVECEXP (exp, 0, 0), 0);
  1686.       cc_status.value2 = XEXP (XVECEXP (exp, 0, 0), 1);
  1687.     }
  1688.     }
  1689.   else
  1690.     CC_STATUS_INIT;
  1691.   if (cc_status.value2 != 0
  1692.       && ADDRESS_REG_P (cc_status.value2)
  1693.       && GET_MODE (cc_status.value2) == QImode)
  1694.     CC_STATUS_INIT;
  1695.   if (cc_status.value2 != 0
  1696.       && !(cc_status.value1 && FPA_REG_P (cc_status.value1)))
  1697.     switch (GET_CODE (cc_status.value2))
  1698.       {
  1699.       case PLUS: case MINUS: case MULT:
  1700.       case DIV: case UDIV: case MOD: case UMOD: case NEG:
  1701.       case ASHIFT: case ASHIFTRT: case LSHIFTRT:
  1702.       case ROTATE: case ROTATERT:
  1703.     if (GET_MODE (cc_status.value2) != VOIDmode)
  1704.       cc_status.flags |= CC_NO_OVERFLOW;
  1705.     break;
  1706.       case ZERO_EXTEND:
  1707.     /* (SET r1 (ZERO_EXTEND r2)) on this machine
  1708.        ends with a move insn moving r2 in r2's mode.
  1709.        Thus, the cc's are set for r2.
  1710.        This can set N bit spuriously. */
  1711.     cc_status.flags |= CC_NOT_NEGATIVE; 
  1712.       }
  1713.   if (cc_status.value1 && GET_CODE (cc_status.value1) == REG
  1714.       && cc_status.value2
  1715.       && reg_overlap_mentioned_p (cc_status.value1, cc_status.value2))
  1716.     cc_status.value2 = 0;
  1717.   if (((cc_status.value1 && FP_REG_P (cc_status.value1))
  1718.        || (cc_status.value2 && FP_REG_P (cc_status.value2)))
  1719.       && !((cc_status.value1 && FPA_REG_P (cc_status.value1))
  1720.        || (cc_status.value2 && FPA_REG_P (cc_status.value2))))
  1721.     cc_status.flags = CC_IN_68881;
  1722. }
  1723.  
  1724. char *
  1725. output_move_const_double (operands)
  1726.      rtx *operands;
  1727. {
  1728. #ifdef SUPPORT_SUN_FPA
  1729.   if (TARGET_FPA && FPA_REG_P (operands[0]))
  1730.     {
  1731.       int code = standard_sun_fpa_constant_p (operands[1]);
  1732.  
  1733.       if (code != 0)
  1734.     {
  1735.       static char buf[40];
  1736.  
  1737.       sprintf (buf, "fpmove%%.d %%%%%d,%%0", code & 0x1ff);
  1738.       return buf;
  1739.     }
  1740.       return "fpmove%.d %1,%0";
  1741.     }
  1742.   else
  1743. #endif
  1744.     {
  1745.       int code = standard_68881_constant_p (operands[1]);
  1746.  
  1747.       if (code != 0)
  1748.     {
  1749.       static char buf[40];
  1750.  
  1751.       sprintf (buf, "fmovecr %%#0x%x,%%0", code & 0xff);
  1752.       return buf;
  1753.     }
  1754.       return "fmove%.d %1,%0";
  1755.     }
  1756. }
  1757.  
  1758. char *
  1759. output_move_const_single (operands)
  1760.      rtx *operands;
  1761. {
  1762. #ifdef SUPPORT_SUN_FPA
  1763.   if (TARGET_FPA)
  1764.     {
  1765.       int code = standard_sun_fpa_constant_p (operands[1]);
  1766.  
  1767.       if (code != 0)
  1768.     {
  1769.       static char buf[40];
  1770.  
  1771.       sprintf (buf, "fpmove%%.s %%%%%d,%%0", code & 0x1ff);
  1772.       return buf;
  1773.     }
  1774.       return "fpmove%.s %1,%0";
  1775.     }
  1776.   else
  1777. #endif /* defined SUPPORT_SUN_FPA */
  1778.     {
  1779.       int code = standard_68881_constant_p (operands[1]);
  1780.  
  1781.       if (code != 0)
  1782.     {
  1783.       static char buf[40];
  1784.  
  1785.       sprintf (buf, "fmovecr %%#0x%x,%%0", code & 0xff);
  1786.       return buf;
  1787.     }
  1788.       return "fmove%.s %f1,%0";
  1789.     }
  1790. }
  1791.  
  1792. /* Return nonzero if X, a CONST_DOUBLE, has a value that we can get
  1793.    from the "fmovecr" instruction.
  1794.    The value, anded with 0xff, gives the code to use in fmovecr
  1795.    to get the desired constant.  */
  1796.  
  1797. /* This code has been fixed for cross-compilation. */
  1798.   
  1799. static int inited_68881_table = 0;
  1800.  
  1801. char *strings_68881[7] = {
  1802.   "0.0",
  1803.   "1.0",
  1804.   "10.0",
  1805.   "100.0",
  1806.   "10000.0",
  1807.   "1e8",
  1808.   "1e16"
  1809.   };
  1810.  
  1811. int codes_68881[7] = {
  1812.   0x0f,
  1813.   0x32,
  1814.   0x33,
  1815.   0x34,
  1816.   0x35,
  1817.   0x36,
  1818.   0x37
  1819.   };
  1820.  
  1821. REAL_VALUE_TYPE values_68881[7];
  1822.  
  1823. /* Set up values_68881 array by converting the decimal values
  1824.    strings_68881 to binary.   */
  1825.  
  1826. void
  1827. init_68881_table ()
  1828. {
  1829.   int i;
  1830.   REAL_VALUE_TYPE r;
  1831.   enum machine_mode mode;
  1832.  
  1833.   mode = DFmode;
  1834.   for (i = 0; i < 7; i++)
  1835.     {
  1836.       if (i == 6)
  1837.         mode = SFmode;
  1838.       r = REAL_VALUE_ATOF (strings_68881[i], mode);
  1839.       values_68881[i] = r;
  1840.     }
  1841.   inited_68881_table = 1;
  1842. }
  1843.  
  1844. int
  1845. standard_68881_constant_p (x)
  1846.      rtx x;
  1847. {
  1848.   REAL_VALUE_TYPE r;
  1849.   int i;
  1850.   enum machine_mode mode;
  1851.  
  1852. #ifdef NO_ASM_FMOVECR
  1853.   return 0;
  1854. #endif
  1855.  
  1856.   /* fmovecr must be emulated on the 68040, so it shouldn't be used at all. */
  1857.   if (TARGET_68040)
  1858.     return 0;
  1859.  
  1860. #ifndef REAL_ARITHMETIC
  1861. #if HOST_FLOAT_FORMAT != TARGET_FLOAT_FORMAT
  1862.   if (! flag_pretend_float)
  1863.     return 0;
  1864. #endif
  1865. #endif
  1866.  
  1867.   if (! inited_68881_table)
  1868.     init_68881_table ();
  1869.  
  1870.   REAL_VALUE_FROM_CONST_DOUBLE (r, x);
  1871.  
  1872.   for (i = 0; i < 6; i++)
  1873.     {
  1874.       if (REAL_VALUES_EQUAL (r, values_68881[i]))
  1875.         return (codes_68881[i]);
  1876.     }
  1877.   
  1878.   if (GET_MODE (x) == SFmode)
  1879.     return 0;
  1880.  
  1881.   if (REAL_VALUES_EQUAL (r, values_68881[6]))
  1882.     return (codes_68881[6]);
  1883.  
  1884.   /* larger powers of ten in the constants ram are not used
  1885.      because they are not equal to a `double' C constant.  */
  1886.   return 0;
  1887. }
  1888.  
  1889. /* If X is a floating-point constant, return the logarithm of X base 2,
  1890.    or 0 if X is not a power of 2.  */
  1891.  
  1892. int
  1893. floating_exact_log2 (x)
  1894.      rtx x;
  1895. {
  1896.   REAL_VALUE_TYPE r, r1;
  1897.   int i;
  1898.  
  1899. #ifndef REAL_ARITHMETIC
  1900. #if HOST_FLOAT_FORMAT != TARGET_FLOAT_FORMAT
  1901.   if (! flag_pretend_float)
  1902.     return 0;
  1903. #endif
  1904. #endif
  1905.  
  1906.   REAL_VALUE_FROM_CONST_DOUBLE (r, x);
  1907.  
  1908.   if (REAL_VALUES_LESS (r, dconst0))
  1909.     return 0;
  1910.  
  1911.   r1 = dconst1;
  1912.   i = 0;
  1913.   while (REAL_VALUES_LESS (r1, r))
  1914.     {
  1915.       r1 = REAL_VALUE_LDEXP (dconst1, i);
  1916.       if (REAL_VALUES_EQUAL (r1, r))
  1917.         return i;
  1918.       i = i + 1;
  1919.     }
  1920.   return 0;
  1921. }
  1922.  
  1923. #ifdef SUPPORT_SUN_FPA
  1924. /* Return nonzero if X, a CONST_DOUBLE, has a value that we can get
  1925.    from the Sun FPA's constant RAM.
  1926.    The value returned, anded with 0x1ff, gives the code to use in fpmove
  1927.    to get the desired constant. */
  1928.  
  1929. static int inited_FPA_table = 0;
  1930.  
  1931. char *strings_FPA[38] = {
  1932. /* small rationals */
  1933.   "0.0",
  1934.   "1.0",
  1935.   "0.5",
  1936.   "-1.0",
  1937.   "2.0",
  1938.   "3.0",
  1939.   "4.0",
  1940.   "8.0",
  1941.   "0.25",
  1942.   "0.125",
  1943.   "10.0",
  1944.   "-0.5",
  1945. /* Decimal equivalents of double precision values */
  1946.   "2.718281828459045091", /* D_E */
  1947.   "6.283185307179586477", /* 2 pi */
  1948.   "3.141592653589793116", /* D_PI */
  1949.   "1.570796326794896619", /* pi/2 */
  1950.   "1.414213562373095145", /* D_SQRT2 */
  1951.   "0.7071067811865475244", /* 1/sqrt(2) */
  1952.   "-1.570796326794896619", /* -pi/2 */
  1953.   "1.442695040888963387", /* D_LOG2ofE */
  1954.   "3.321928024887362182", /* D_LOG2of10 */
  1955.   "0.6931471805599452862", /* D_LOGEof2 */
  1956.   "2.302585092994045901", /* D_LOGEof10 */
  1957.   "0.3010299956639811980", /* D_LOG10of2 */
  1958.   "0.4342944819032518167", /* D_LOG10ofE */
  1959. /* Decimal equivalents of single precision values */
  1960.   "2.718281745910644531", /* S_E */
  1961.   "6.283185307179586477", /* 2 pi */
  1962.   "3.141592741012573242", /* S_PI */
  1963.   "1.570796326794896619", /* pi/2 */
  1964.   "1.414213538169860840", /* S_SQRT2 */
  1965.   "0.7071067811865475244", /* 1/sqrt(2) */
  1966.   "-1.570796326794896619", /* -pi/2 */
  1967.   "1.442695021629333496", /* S_LOG2ofE */
  1968.   "3.321928024291992188", /* S_LOG2of10 */
  1969.   "0.6931471824645996094", /* S_LOGEof2 */
  1970.   "2.302585124969482442", /* S_LOGEof10 */
  1971.   "0.3010300099849700928", /* S_LOG10of2 */
  1972.   "0.4342944920063018799", /* S_LOG10ofE */
  1973. };
  1974.  
  1975.  
  1976. int codes_FPA[38] = {
  1977. /* small rationals */
  1978.   0x200,
  1979.   0xe,
  1980.   0xf,
  1981.   0x10,
  1982.   0x11,
  1983.   0xb1,
  1984.   0x12,
  1985.   0x13,
  1986.   0x15,
  1987.   0x16,
  1988.   0x17,
  1989.   0x2e,
  1990. /* double precision */
  1991.   0x8,
  1992.   0x9,
  1993.   0xa,
  1994.   0xb,
  1995.   0xc,
  1996.   0xd,
  1997.   0x27,
  1998.   0x28,
  1999.   0x29,
  2000.   0x2a,
  2001.   0x2b,
  2002.   0x2c,
  2003.   0x2d,
  2004. /* single precision */
  2005.   0x8,
  2006.   0x9,
  2007.   0xa,
  2008.   0xb,
  2009.   0xc,
  2010.   0xd,
  2011.   0x27,
  2012.   0x28,
  2013.   0x29,
  2014.   0x2a,
  2015.   0x2b,
  2016.   0x2c,
  2017.   0x2d
  2018.   };
  2019.  
  2020. REAL_VALUE_TYPE values_FPA[38];
  2021.  
  2022. /* This code has been fixed for cross-compilation. */
  2023.  
  2024. void
  2025. init_FPA_table ()
  2026. {
  2027.   enum machine_mode mode;
  2028.   int i;
  2029.   REAL_VALUE_TYPE r;
  2030.  
  2031.   mode = DFmode;
  2032.   for (i = 0; i < 38; i++)
  2033.     {
  2034.       if (i == 25)
  2035.         mode = SFmode;
  2036.       r = REAL_VALUE_ATOF (strings_FPA[i], mode);
  2037.       values_FPA[i] = r;
  2038.     }
  2039.   inited_FPA_table = 1;
  2040. }
  2041.  
  2042.  
  2043. int
  2044. standard_sun_fpa_constant_p (x)
  2045.      rtx x;
  2046. {
  2047.   REAL_VALUE_TYPE r;
  2048.   int i;
  2049.  
  2050. #ifndef REAL_ARITHMETIC
  2051. #if HOST_FLOAT_FORMAT != TARGET_FLOAT_FORMAT
  2052.   if (! flag_pretend_float)
  2053.     return 0;
  2054. #endif
  2055. #endif
  2056.  
  2057.   if (! inited_FPA_table)
  2058.     init_FPA_table ();
  2059.  
  2060.   REAL_VALUE_FROM_CONST_DOUBLE (r, x);
  2061.  
  2062.   for (i=0; i<12; i++)
  2063.     {
  2064.       if (REAL_VALUES_EQUAL (r, values_FPA[i]))
  2065.         return (codes_FPA[i]);
  2066.     }
  2067.  
  2068.   if (GET_MODE (x) == SFmode)
  2069.     {
  2070.       for (i=25; i<38; i++)
  2071.         {
  2072.           if (REAL_VALUES_EQUAL (r, values_FPA[i]))
  2073.             return (codes_FPA[i]);
  2074.         }
  2075.     }
  2076.   else
  2077.     {
  2078.       for (i=12; i<25; i++)
  2079.         {
  2080.           if (REAL_VALUES_EQUAL (r, values_FPA[i]))
  2081.             return (codes_FPA[i]);
  2082.         }
  2083.     }
  2084.   return 0x0;
  2085. }
  2086. #endif /* define SUPPORT_SUN_FPA */
  2087.  
  2088. /* A C compound statement to output to stdio stream STREAM the
  2089.    assembler syntax for an instruction operand X.  X is an RTL
  2090.    expression.
  2091.  
  2092.    CODE is a value that can be used to specify one of several ways
  2093.    of printing the operand.  It is used when identical operands
  2094.    must be printed differently depending on the context.  CODE
  2095.    comes from the `%' specification that was used to request
  2096.    printing of the operand.  If the specification was just `%DIGIT'
  2097.    then CODE is 0; if the specification was `%LTR DIGIT' then CODE
  2098.    is the ASCII code for LTR.
  2099.  
  2100.    If X is a register, this macro should print the register's name.
  2101.    The names can be found in an array `reg_names' whose type is
  2102.    `char *[]'.  `reg_names' is initialized from `REGISTER_NAMES'.
  2103.  
  2104.    When the machine description has a specification `%PUNCT' (a `%'
  2105.    followed by a punctuation character), this macro is called with
  2106.    a null pointer for X and the punctuation character for CODE.
  2107.  
  2108.    The m68k specific codes are:
  2109.  
  2110.    '.' for dot needed in Motorola-style opcode names.
  2111.    '-' for an operand pushing on the stack:
  2112.        sp@-, -(sp) or -(%sp) depending on the style of syntax.
  2113.    '+' for an operand pushing on the stack:
  2114.        sp@+, (sp)+ or (%sp)+ depending on the style of syntax.
  2115.    '@' for a reference to the top word on the stack:
  2116.        sp@, (sp) or (%sp) depending on the style of syntax.
  2117.    '#' for an immediate operand prefix (# in MIT and Motorola syntax
  2118.        but & in SGS syntax).
  2119.    '!' for the cc register (used in an `and to cc' insn).
  2120.    '$' for the letter `s' in an op code, but only on the 68040.
  2121.    '&' for the letter `d' in an op code, but only on the 68040.
  2122.    '/' for register prefix needed by longlong.h.
  2123.  
  2124.    'b' for byte insn (no effect, on the Sun; this is for the ISI).
  2125.    'd' to force memory addressing to be absolute, not relative.
  2126.    'f' for float insn (print a CONST_DOUBLE as a float rather than in hex)
  2127.    'w' for FPA insn (print a CONST_DOUBLE as a SunFPA constant rather
  2128.        than directly).  Second part of 'y' below.
  2129.    'x' for float insn (print a CONST_DOUBLE as a float rather than in hex),
  2130.        or print pair of registers as rx:ry.
  2131.    'y' for a FPA insn (print pair of registers as rx:ry).  This also outputs
  2132.        CONST_DOUBLE's as SunFPA constant RAM registers if
  2133.        possible, so it should not be used except for the SunFPA.
  2134.  
  2135.    */
  2136.  
  2137. void
  2138. print_operand (file, op, letter)
  2139.      FILE *file;        /* file to write to */
  2140.      rtx op;            /* operand to print */
  2141.      int letter;        /* %<letter> or 0 */
  2142. {
  2143.   int i;
  2144.  
  2145.   if (letter == '.')
  2146.     {
  2147. #ifdef MOTOROLA
  2148.       asm_fprintf (file, ".");
  2149. #endif
  2150.     }
  2151.   else if (letter == '#')
  2152.     {
  2153.       asm_fprintf (file, "%0I");
  2154.     }
  2155.   else if (letter == '-')
  2156.     {
  2157. #ifdef MOTOROLA
  2158.       asm_fprintf (file, "-(%Rsp)");
  2159. #else
  2160.       asm_fprintf (file, "%Rsp@-");
  2161. #endif
  2162.     }
  2163.   else if (letter == '+')
  2164.     {
  2165. #ifdef MOTOROLA
  2166.       asm_fprintf (file, "(%Rsp)+");
  2167. #else
  2168.       asm_fprintf (file, "%Rsp@+");
  2169. #endif
  2170.     }
  2171.   else if (letter == '@')
  2172.     {
  2173. #ifdef MOTOROLA
  2174.       asm_fprintf (file, "(%Rsp)");
  2175. #else
  2176.       asm_fprintf (file, "%Rsp@");
  2177. #endif
  2178.     }
  2179.   else if (letter == '!')
  2180.     {
  2181.       asm_fprintf (file, "%Rfpcr");
  2182.     }
  2183.   else if (letter == '$')
  2184.     {
  2185.       if (TARGET_68040_ONLY)
  2186.     {
  2187.       fprintf (file, "s");
  2188.     }
  2189.     }
  2190.   else if (letter == '&')
  2191.     {
  2192.       if (TARGET_68040_ONLY)
  2193.     {
  2194.       fprintf (file, "d");
  2195.     }
  2196.     }
  2197.   else if (letter == '/')
  2198.     {
  2199.       asm_fprintf (file, "%R");
  2200.     }
  2201.   else if (GET_CODE (op) == REG)
  2202.     {
  2203. #ifdef SUPPORT_SUN_FPA
  2204.       if (REGNO (op) < 16
  2205.       && (letter == 'y' || letter == 'x')
  2206.       && GET_MODE (op) == DFmode)
  2207.     {
  2208.       fprintf (file, "%s:%s", reg_names[REGNO (op)],
  2209.            reg_names[REGNO (op)+1]);
  2210.     }
  2211.       else
  2212. #endif
  2213.     {
  2214.       if (letter == 'R')
  2215.         /* Print out the second register name of a register pair.
  2216.            I.e., R (6) => 7.  */
  2217.         fputs (reg_names[REGNO (op) + 1], file);
  2218.       else
  2219.         fputs (reg_names[REGNO (op)], file);
  2220.     }
  2221.     }
  2222.   else if (GET_CODE (op) == MEM)
  2223.     {
  2224.       output_address (XEXP (op, 0));
  2225.       if (letter == 'd' && ! TARGET_68020
  2226.       && CONSTANT_ADDRESS_P (XEXP (op, 0))
  2227.       && !(GET_CODE (XEXP (op, 0)) == CONST_INT
  2228.            && INTVAL (XEXP (op, 0)) < 0x8000
  2229.            && INTVAL (XEXP (op, 0)) >= -0x8000))
  2230.     {
  2231.       fprintf (file, ":l");
  2232.     }
  2233.     }
  2234. #ifdef SUPPORT_SUN_FPA
  2235.   else if ((letter == 'y' || letter == 'w')
  2236.        && GET_CODE (op) == CONST_DOUBLE
  2237.        && (i = standard_sun_fpa_constant_p (op)))
  2238.     {
  2239.       fprintf (file, "%%%d", i & 0x1ff);
  2240.     }
  2241. #endif
  2242.   else if (GET_CODE (op) == CONST_DOUBLE && GET_MODE (op) == SFmode)
  2243.     {
  2244.       REAL_VALUE_TYPE r;
  2245.       REAL_VALUE_FROM_CONST_DOUBLE (r, op);
  2246.       ASM_OUTPUT_FLOAT_OPERAND (letter, file, r);
  2247.     }
  2248.   else if (GET_CODE (op) == CONST_DOUBLE && GET_MODE (op) == XFmode)
  2249.     {
  2250.       REAL_VALUE_TYPE r;
  2251.       REAL_VALUE_FROM_CONST_DOUBLE (r, op);
  2252.       ASM_OUTPUT_LONG_DOUBLE_OPERAND (file, r);
  2253.     }
  2254.   else if (GET_CODE (op) == CONST_DOUBLE && GET_MODE (op) == DFmode)
  2255.     {
  2256.       REAL_VALUE_TYPE r;
  2257.       REAL_VALUE_FROM_CONST_DOUBLE (r, op);
  2258.       ASM_OUTPUT_DOUBLE_OPERAND (file, r);
  2259.     }
  2260.   else
  2261.     {
  2262.       asm_fprintf (file, "%0I"); output_addr_const (file, op);
  2263.     }
  2264. }
  2265.  
  2266.  
  2267. /* A C compound statement to output to stdio stream STREAM the
  2268.    assembler syntax for an instruction operand that is a memory
  2269.    reference whose address is ADDR.  ADDR is an RTL expression.
  2270.  
  2271.    Note that this contains a kludge that knows that the only reason
  2272.    we have an address (plus (label_ref...) (reg...)) when not generating
  2273.    PIC code is in the insn before a tablejump, and we know that m68k.md
  2274.    generates a label LInnn: on such an insn.
  2275.  
  2276.    It is possible for PIC to generate a (plus (label_ref...) (reg...))
  2277.    and we handle that just like we would a (plus (symbol_ref...) (reg...)).
  2278.  
  2279.    Some SGS assemblers have a bug such that "Lnnn-LInnn-2.b(pc,d0.l*2)"
  2280.    fails to assemble.  Luckily "Lnnn(pc,d0.l*2)" produces the results
  2281.    we want.  This difference can be accommodated by using an assembler
  2282.    define such "LDnnn" to be either "Lnnn-LInnn-2.b", "Lnnn", or any other
  2283.    string, as necessary.  This is accomplished via the ASM_OUTPUT_CASE_END
  2284.    macro.  See m68k/sgs.h for an example; for versions without the bug.
  2285.    Some assemblers refuse all the above solutions.  The workaround is to
  2286.    emit "K(pc,d0.l*2)" with K being a small constant known to give the
  2287.    right behaviour.
  2288.  
  2289.    They also do not like things like "pea 1.w", so we simple leave off
  2290.    the .w on small constants. 
  2291.  
  2292.    This routine is responsible for distinguishing between -fpic and -fPIC 
  2293.    style relocations in an address.  When generating -fpic code the
  2294.    offset is output in word mode (eg movel a5@(_foo:w), a0).  When generating
  2295.    -fPIC code the offset is output in long mode (eg movel a5@(_foo:l), a0) */
  2296.  
  2297. #ifndef ASM_OUTPUT_CASE_FETCH
  2298. #ifdef MOTOROLA
  2299. #ifdef SGS
  2300. #define ASM_OUTPUT_CASE_FETCH(file, labelno, regname)\
  2301.     asm_fprintf (file, "%LLD%d(%Rpc,%s.", labelno, regname)
  2302. #else
  2303. #define ASM_OUTPUT_CASE_FETCH(file, labelno, regname)\
  2304.     asm_fprintf (file, "%LL%d-%LLI%d.b(%Rpc,%s.", labelno, labelno, regname)
  2305. #endif
  2306. #else
  2307. #define ASM_OUTPUT_CASE_FETCH(file, labelno, regname)\
  2308.     asm_fprintf (file, "%Rpc@(%LL%d-%LLI%d-2:b,%s:", labelno, labelno, regname)
  2309. #endif
  2310. #endif /* ASM_OUTPUT_CASE_FETCH */
  2311.  
  2312. void
  2313. print_operand_address (file, addr)
  2314.      FILE *file;
  2315.      rtx addr;
  2316. {
  2317.   register rtx reg1, reg2, breg, ireg;
  2318.   rtx offset;
  2319.  
  2320.   switch (GET_CODE (addr))
  2321.     {
  2322.       case REG:
  2323. #ifdef MOTOROLA
  2324.     fprintf (file, "(%s)", reg_names[REGNO (addr)]);
  2325. #else
  2326.     fprintf (file, "%s@", reg_names[REGNO (addr)]);
  2327. #endif
  2328.     break;
  2329.       case PRE_DEC:
  2330. #ifdef MOTOROLA
  2331.     fprintf (file, "-(%s)", reg_names[REGNO (XEXP (addr, 0))]);
  2332. #else
  2333.     fprintf (file, "%s@-", reg_names[REGNO (XEXP (addr, 0))]);
  2334. #endif
  2335.     break;
  2336.       case POST_INC:
  2337. #ifdef MOTOROLA
  2338.     fprintf (file, "(%s)+", reg_names[REGNO (XEXP (addr, 0))]);
  2339. #else
  2340.     fprintf (file, "%s@+", reg_names[REGNO (XEXP (addr, 0))]);
  2341. #endif
  2342.     break;
  2343.       case PLUS:
  2344.     reg1 = reg2 = ireg = breg = offset = 0;
  2345.     if (CONSTANT_ADDRESS_P (XEXP (addr, 0)))
  2346.       {
  2347.         offset = XEXP (addr, 0);
  2348.         addr = XEXP (addr, 1);
  2349.       }
  2350.     else if (CONSTANT_ADDRESS_P (XEXP (addr, 1)))
  2351.       {
  2352.         offset = XEXP (addr, 1);
  2353.         addr = XEXP (addr, 0);
  2354.       }
  2355.     if (GET_CODE (addr) != PLUS)
  2356.       {
  2357.         ;
  2358.       }
  2359.     else if (GET_CODE (XEXP (addr, 0)) == SIGN_EXTEND)
  2360.       {
  2361.         reg1 = XEXP (addr, 0);
  2362.         addr = XEXP (addr, 1);
  2363.       }
  2364.     else if (GET_CODE (XEXP (addr, 1)) == SIGN_EXTEND)
  2365.       {
  2366.         reg1 = XEXP (addr, 1);
  2367.         addr = XEXP (addr, 0);
  2368.       }
  2369.     else if (GET_CODE (XEXP (addr, 0)) == MULT)
  2370.       {
  2371.         reg1 = XEXP (addr, 0);
  2372.         addr = XEXP (addr, 1);
  2373.       }
  2374.     else if (GET_CODE (XEXP (addr, 1)) == MULT)
  2375.       {
  2376.         reg1 = XEXP (addr, 1);
  2377.         addr = XEXP (addr, 0);
  2378.       }
  2379.     else if (GET_CODE (XEXP (addr, 0)) == REG)
  2380.       {
  2381.         reg1 = XEXP (addr, 0);
  2382.         addr = XEXP (addr, 1);
  2383.       }
  2384.     else if (GET_CODE (XEXP (addr, 1)) == REG)
  2385.       {
  2386.         reg1 = XEXP (addr, 1);
  2387.         addr = XEXP (addr, 0);
  2388.       }
  2389.     if (GET_CODE (addr) == REG || GET_CODE (addr) == MULT
  2390.         || GET_CODE (addr) == SIGN_EXTEND)
  2391.       {
  2392.         if (reg1 == 0)
  2393.           {
  2394.         reg1 = addr;
  2395.           }
  2396.         else
  2397.           {
  2398.         reg2 = addr;
  2399.           }
  2400.         addr = 0;
  2401.       }
  2402. #if 0    /* for OLD_INDEXING */
  2403.     else if (GET_CODE (addr) == PLUS)
  2404.       {
  2405.         if (GET_CODE (XEXP (addr, 0)) == REG)
  2406.           {
  2407.         reg2 = XEXP (addr, 0);
  2408.         addr = XEXP (addr, 1);
  2409.           }
  2410.         else if (GET_CODE (XEXP (addr, 1)) == REG)
  2411.           {
  2412.         reg2 = XEXP (addr, 1);
  2413.         addr = XEXP (addr, 0);
  2414.           }
  2415.       }
  2416. #endif
  2417.     if (offset != 0)
  2418.       {
  2419.         if (addr != 0)
  2420.           {
  2421.         abort ();
  2422.           }
  2423.         addr = offset;
  2424.       }
  2425.     if ((reg1 && (GET_CODE (reg1) == SIGN_EXTEND
  2426.               || GET_CODE (reg1) == MULT))
  2427.         || (reg2 != 0 && REGNO_OK_FOR_BASE_P (REGNO (reg2))))
  2428.       {
  2429.         breg = reg2;
  2430.         ireg = reg1;
  2431.       }
  2432.     else if (reg1 != 0 && REGNO_OK_FOR_BASE_P (REGNO (reg1)))
  2433.       {
  2434.         breg = reg1;
  2435.         ireg = reg2;
  2436.       }
  2437.     if (ireg != 0 && breg == 0 && GET_CODE (addr) == LABEL_REF
  2438.         && ! (flag_pic && ireg == pic_offset_table_rtx))
  2439.       {
  2440.         int scale = 1;
  2441.         if (GET_CODE (ireg) == MULT)
  2442.           {
  2443.         scale = INTVAL (XEXP (ireg, 1));
  2444.         ireg = XEXP (ireg, 0);
  2445.           }
  2446.         if (GET_CODE (ireg) == SIGN_EXTEND)
  2447.           {
  2448.         ASM_OUTPUT_CASE_FETCH (file,
  2449.                  CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2450.                  reg_names[REGNO (XEXP (ireg, 0))]);
  2451.         fprintf (file, "w");
  2452.           }
  2453.         else
  2454.           {
  2455.         ASM_OUTPUT_CASE_FETCH (file,
  2456.                  CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2457.                  reg_names[REGNO (ireg)]);
  2458.         fprintf (file, "l");
  2459.           }
  2460.         if (scale != 1)
  2461.           {
  2462. #ifdef MOTOROLA
  2463.         fprintf (file, "*%d", scale);
  2464. #else
  2465.         fprintf (file, ":%d", scale);
  2466. #endif
  2467.           }
  2468.         putc (')', file);
  2469.         break;
  2470.       }
  2471.     if (breg != 0 && ireg == 0 && GET_CODE (addr) == LABEL_REF
  2472.         && ! (flag_pic && breg == pic_offset_table_rtx))
  2473.       {
  2474.         ASM_OUTPUT_CASE_FETCH (file,
  2475.              CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2476.              reg_names[REGNO (breg)]);
  2477.         fprintf (file, "l)");
  2478.         break;
  2479.       }
  2480.     if (ireg != 0 || breg != 0)
  2481.       {
  2482.         int scale = 1;
  2483.         if (breg == 0)
  2484.           {
  2485.         abort ();
  2486.           }
  2487.         if (! flag_pic && addr && GET_CODE (addr) == LABEL_REF)
  2488.           {
  2489.         abort ();
  2490.           }
  2491. #ifdef MOTOROLA
  2492.         if (addr != 0)
  2493.           {
  2494.         output_addr_const (file, addr);
  2495.             if (flag_pic && (breg == pic_offset_table_rtx))
  2496.               fprintf (file, "@GOT");
  2497.           }
  2498.         fprintf (file, "(%s", reg_names[REGNO (breg)]);
  2499.         if (ireg != 0)
  2500.           {
  2501.         putc (',', file);
  2502.           }
  2503. #else
  2504.         fprintf (file, "%s@(", reg_names[REGNO (breg)]);
  2505.         if (addr != 0)
  2506.           {
  2507.         output_addr_const (file, addr);
  2508.             if ((flag_pic == 1) && (breg == pic_offset_table_rtx))
  2509.               fprintf (file, ":w");
  2510.             if ((flag_pic == 2) && (breg == pic_offset_table_rtx))
  2511.               fprintf (file, ":l");
  2512.             if ((flag_pic == 3) && (breg == pic_offset_table_rtx))
  2513.               fprintf (file, ":W");
  2514.             if ((flag_pic == 4) && (breg == pic_offset_table_rtx))
  2515.               fprintf (file, ":L");
  2516.           }
  2517.         if (addr != 0 && ireg != 0)
  2518.           {
  2519.         putc (',', file);
  2520.           }
  2521. #endif
  2522.         if (ireg != 0 && GET_CODE (ireg) == MULT)
  2523.           {
  2524.         scale = INTVAL (XEXP (ireg, 1));
  2525.         ireg = XEXP (ireg, 0);
  2526.           }
  2527.         if (ireg != 0 && GET_CODE (ireg) == SIGN_EXTEND)
  2528.           {
  2529. #ifdef MOTOROLA
  2530.         fprintf (file, "%s.w", reg_names[REGNO (XEXP (ireg, 0))]);
  2531. #else
  2532.         fprintf (file, "%s:w", reg_names[REGNO (XEXP (ireg, 0))]);
  2533. #endif
  2534.           }
  2535.         else if (ireg != 0)
  2536.           {
  2537. #ifdef MOTOROLA
  2538.         fprintf (file, "%s.l", reg_names[REGNO (ireg)]);
  2539. #else
  2540.         fprintf (file, "%s:l", reg_names[REGNO (ireg)]);
  2541. #endif
  2542.           }
  2543.         if (scale != 1)
  2544.           {
  2545. #ifdef MOTOROLA
  2546.         fprintf (file, "*%d", scale);
  2547. #else
  2548.         fprintf (file, ":%d", scale);
  2549. #endif
  2550.           }
  2551.         putc (')', file);
  2552.         break;
  2553.       }
  2554.     else if (reg1 != 0 && GET_CODE (addr) == LABEL_REF
  2555.          && ! (flag_pic && reg1 == pic_offset_table_rtx))    
  2556.       {
  2557.         ASM_OUTPUT_CASE_FETCH (file,
  2558.              CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2559.              reg_names[REGNO (reg1)]);
  2560.         fprintf (file, "l)");
  2561.         break;
  2562.       }
  2563.     /* FALL-THROUGH (is this really what we want? */
  2564.       default:
  2565.         if (GET_CODE (addr) == CONST_INT
  2566.         && INTVAL (addr) < 0x8000
  2567.         && INTVAL (addr) >= -0x8000)
  2568.       {
  2569. #ifdef MOTOROLA
  2570. #ifdef SGS
  2571.         /* Many SGS assemblers croak on size specifiers for constants. */
  2572.         fprintf (file, "%d", INTVAL (addr));
  2573. #else
  2574.         fprintf (file, "%d.w", INTVAL (addr));
  2575. #endif
  2576. #else
  2577.         fprintf (file, "%d:w", INTVAL (addr));
  2578. #endif
  2579.       }
  2580.     else
  2581.       {
  2582.         output_addr_const (file, addr);
  2583.       }
  2584.     break;
  2585.     }
  2586. }
  2587.  
  2588. /* Check for cases where a clr insns can be omitted from code using
  2589.    strict_low_part sets.  For example, the second clrl here is not needed:
  2590.    clrl d0; movw a0@+,d0; use d0; clrl d0; movw a0@+; use d0; ...
  2591.  
  2592.    MODE is the mode of this STRICT_LOW_PART set.  FIRST_INSN is the clear
  2593.    insn we are checking for redundancy.  TARGET is the register set by the
  2594.    clear insn.  */
  2595.  
  2596. int
  2597. strict_low_part_peephole_ok (mode, first_insn, target)
  2598.      enum machine_mode mode;
  2599.      rtx first_insn;
  2600.      rtx target;
  2601. {
  2602.   rtx p;
  2603.  
  2604.   p = prev_nonnote_insn (first_insn);
  2605.  
  2606.   while (p)
  2607.     {
  2608.       /* If it isn't an insn, then give up.  */
  2609.       if (GET_CODE (p) != INSN)
  2610.     return 0;
  2611.  
  2612.       if (reg_set_p (target, p))
  2613.     {
  2614.       rtx set = single_set (p);
  2615.       rtx dest;
  2616.  
  2617.       /* If it isn't an easy to recognize insn, then give up.  */
  2618.       if (! set)
  2619.         return 0;
  2620.  
  2621.       dest = SET_DEST (set);
  2622.  
  2623.       /* If this sets the entire target register to zero, then our
  2624.          first_insn is redundant.  */
  2625.       if (rtx_equal_p (dest, target)
  2626.           && SET_SRC (set) == const0_rtx)
  2627.         return 1;
  2628.       else if (GET_CODE (dest) == STRICT_LOW_PART
  2629.            && GET_CODE (XEXP (dest, 0)) == REG
  2630.            && REGNO (XEXP (dest, 0)) == REGNO (target)
  2631.            && (GET_MODE_SIZE (GET_MODE (XEXP (dest, 0)))
  2632.                <= GET_MODE_SIZE (mode)))
  2633.         /* This is a strict low part set which modifies less than
  2634.            we are using, so it is safe.  */
  2635.         ;
  2636.       else
  2637.         return 0;
  2638.     }
  2639.  
  2640.       p = prev_nonnote_insn (p);
  2641.  
  2642.     }
  2643.  
  2644.   return 0;
  2645. }
  2646.  
  2647. /* Accept integer operands in the range 0..0xffffffff.  We have to check the
  2648.    range carefully since this predicate is used in DImode contexts.  Also, we
  2649.    need some extra crud to make it work when hosted on 64-bit machines.  */
  2650.  
  2651. int
  2652. const_uint32_operand (op, mode)
  2653.      rtx op;
  2654.      enum machine_mode mode;
  2655. {
  2656. #if HOST_BITS_PER_WIDE_INT > 32
  2657.   /* All allowed constants will fit a CONST_INT.  */
  2658.   return (GET_CODE (op) == CONST_INT
  2659.       && (INTVAL (op) >= 0 && INTVAL (op) <= 0xffffffffL));
  2660. #else
  2661.   return ((GET_CODE (op) == CONST_INT && INTVAL (op) >= 0)
  2662.       || (GET_CODE (op) == CONST_DOUBLE && CONST_DOUBLE_HIGH (op) == 0));
  2663. #endif
  2664. }
  2665.  
  2666. /* Accept integer operands in the range -0x80000000..0x7fffffff.  We have
  2667.    to check the range carefully since this predicate is used in DImode
  2668.    contexts.  */
  2669.  
  2670. int
  2671. const_sint32_operand (op, mode)
  2672.      rtx op;
  2673.      enum machine_mode mode;
  2674. {
  2675.   /* All allowed constants will fit a CONST_INT.  */
  2676.   return (GET_CODE (op) == CONST_INT
  2677.       && (INTVAL (op) >= (-0x7fffffff - 1) && INTVAL (op) <= 0x7fffffff));
  2678. }
  2679.